wireguard: implement MarshalYAML for PrivateKey and PublicKey
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -70,6 +70,24 @@ func encodeKeyJSON(s string) ([]byte, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MarshalYAML encodes the key for YAML, omiting empty.
|
||||
func (key PrivateKey) MarshalYAML() (any, error) {
|
||||
return encodeKeyYAML(key.String())
|
||||
}
|
||||
|
||||
// MarshalYAML encodes the key for YAML, omiting empty.
|
||||
func (pub PublicKey) MarshalYAML() (any, error) {
|
||||
return encodeKeyYAML(pub.String())
|
||||
}
|
||||
|
||||
func encodeKeyYAML(s string) (any, error) {
|
||||
if s == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// IsZero tells if the key hasn't been set
|
||||
func (key PrivateKey) IsZero() bool {
|
||||
var zero PrivateKey
|
||||
|
||||
Reference in New Issue
Block a user