Skip to content

Commit 603553a

Browse files
committed
comments
1 parent bcb95d4 commit 603553a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

coderd/database/dbtypes/wireguard.go renamed to coderd/database/dbtypes/dbtypes.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,28 @@ import (
77
"tailscale.com/types/key"
88
)
99

10+
// NodePublic is a wrapper around a key.NodePublic which represents the
11+
// Wireguard public key for an agent..
1012
type NodePublic key.NodePublic
1113

1214
func (n NodePublic) String() string {
1315
return key.NodePublic(n).String()
1416
}
1517

18+
// This is necessary so NodePublic can be serialized in JSON loggers.
1619
func (n NodePublic) MarshalJSON() ([]byte, error) {
1720
j, err := key.NodePublic(n).MarshalText()
1821
// surround in quotes to make it a JSON string
19-
j = append([]byte{'"'}, j...)
20-
j = append(j, '"')
22+
j = append([]byte{'"'}, append(j, '"')...)
2123
return j, err
2224
}
2325

26+
// Value is so NodePublic can be inserted into the database.
2427
func (n NodePublic) Value() (driver.Value, error) {
2528
return key.NodePublic(n).MarshalText()
2629
}
2730

31+
// Scan is so NodePublic can be read from the database.
2832
func (n *NodePublic) Scan(value interface{}) error {
2933
switch v := value.(type) {
3034
case []byte:
@@ -36,24 +40,28 @@ func (n *NodePublic) Scan(value interface{}) error {
3640
}
3741
}
3842

43+
// NodePublic is a wrapper around a key.NodePublic which represents the
44+
// Tailscale disco key for an agent.
3945
type DiscoPublic key.DiscoPublic
4046

4147
func (n DiscoPublic) String() string {
4248
return key.DiscoPublic(n).String()
4349
}
4450

51+
// This is necessary so DiscoPublic can be serialized in JSON loggers.
4552
func (n DiscoPublic) MarshalJSON() ([]byte, error) {
4653
j, err := key.DiscoPublic(n).MarshalText()
4754
// surround in quotes to make it a JSON string
48-
j = append([]byte{'"'}, j...)
49-
j = append(j, '"')
55+
j = append([]byte{'"'}, append(j, '"')...)
5056
return j, err
5157
}
5258

59+
// Value is so DiscoPublic can be inserted into the database.
5360
func (n DiscoPublic) Value() (driver.Value, error) {
5461
return key.DiscoPublic(n).MarshalText()
5562
}
5663

64+
// Scan is so DiscoPublic can be read from the database.
5765
func (n *DiscoPublic) Scan(value interface{}) error {
5866
switch v := value.(type) {
5967
case []byte:

0 commit comments

Comments
 (0)