pkg/types: Add UnmarshallableString type
Allow strings to be unmarshalled for CNI_ARGS CNI_ARGS uses types.LoadArgs to populate a struct. The fields in the struct must meet the TextUnmarshaler interface. This code adds a UnmarshallableString type to assist with this.
This commit is contained in:
parent
e90d8c12b1
commit
031567c216
@ -41,6 +41,16 @@ func (b *UnmarshallableBool) UnmarshalText(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshallableString typedef for builtin string
|
||||||
|
type UnmarshallableString string
|
||||||
|
|
||||||
|
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
||||||
|
// Returns the string
|
||||||
|
func (s *UnmarshallableString) UnmarshalText(data []byte) error {
|
||||||
|
*s = UnmarshallableString(data)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// CommonArgs contains the IgnoreUnknown argument
|
// CommonArgs contains the IgnoreUnknown argument
|
||||||
// and must be embedded by all Arg structs
|
// and must be embedded by all Arg structs
|
||||||
type CommonArgs struct {
|
type CommonArgs struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user