Skip to content

Commit bcb95d4

Browse files
committed
fixup! Merge branch 'main' into colin/wg-db-typed
1 parent b5ae80b commit bcb95d4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

coderd/database/dbtypes/wireguard.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ import (
99

1010
type NodePublic key.NodePublic
1111

12+
func (n NodePublic) String() string {
13+
return key.NodePublic(n).String()
14+
}
15+
16+
func (n NodePublic) MarshalJSON() ([]byte, error) {
17+
j, err := key.NodePublic(n).MarshalText()
18+
// surround in quotes to make it a JSON string
19+
j = append([]byte{'"'}, j...)
20+
j = append(j, '"')
21+
return j, err
22+
}
23+
1224
func (n NodePublic) Value() (driver.Value, error) {
1325
return key.NodePublic(n).MarshalText()
1426
}
@@ -26,6 +38,18 @@ func (n *NodePublic) Scan(value interface{}) error {
2638

2739
type DiscoPublic key.DiscoPublic
2840

41+
func (n DiscoPublic) String() string {
42+
return key.DiscoPublic(n).String()
43+
}
44+
45+
func (n DiscoPublic) MarshalJSON() ([]byte, error) {
46+
j, err := key.DiscoPublic(n).MarshalText()
47+
// surround in quotes to make it a JSON string
48+
j = append([]byte{'"'}, j...)
49+
j = append(j, '"')
50+
return j, err
51+
}
52+
2953
func (n DiscoPublic) Value() (driver.Value, error) {
3054
return key.DiscoPublic(n).MarshalText()
3155
}

0 commit comments

Comments
 (0)