jpictl: fix cloud.yaml unmarshalling #32
@@ -107,6 +107,11 @@ func (ep EndpointAddress) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshalText loads an endpoint address from text data
|
||||||
|
func (ep *EndpointAddress) UnmarshalText(b []byte) error {
|
||||||
|
return ep.FromString(string(b))
|
||||||
|
}
|
||||||
|
|
||||||
// FromString sets the EndpointAddress from a given "[host]:port"
|
// FromString sets the EndpointAddress from a given "[host]:port"
|
||||||
func (ep *EndpointAddress) FromString(s string) error {
|
func (ep *EndpointAddress) FromString(s string) error {
|
||||||
host, port, err := core.SplitHostPort(s)
|
host, port, err := core.SplitHostPort(s)
|
||||||
|
|||||||
@@ -51,6 +51,28 @@ func (pub PublicKey) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshalText loads the value from base64
|
||||||
|
func (key *PrivateKey) UnmarshalText(b []byte) error {
|
||||||
|
v, err := PrivateKeyFromBase64(string(b))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
*key = v
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalText loads the value from base64
|
||||||
|
func (pub *PublicKey) UnmarshalText(b []byte) error {
|
||||||
|
v, err := PublicKeyFromBase64(string(b))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
*pub = v
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// MarshalJSON encodes the key for JSON, omitting empty.
|
// MarshalJSON encodes the key for JSON, omitting empty.
|
||||||
func (key PrivateKey) MarshalJSON() ([]byte, error) {
|
func (key PrivateKey) MarshalJSON() ([]byte, error) {
|
||||||
return encodeKeyJSON(key.String())
|
return encodeKeyJSON(key.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user