mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-28 02:37:11 +00:00
Merge pull request #1087 from marquiz/devel/strigsetval
pkg/utils: add UnmarshalJSON method to StringSetVal
This commit is contained in:
commit
6688a2f232
1 changed files with 12 additions and 0 deletions
|
@ -84,6 +84,18 @@ func (a *StringSetVal) String() string {
|
|||
return strings.Join(vals, ",")
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the Unmarshaler interface from "encoding/json"
|
||||
func (a *StringSetVal) UnmarshalJSON(data []byte) error {
|
||||
var tmp []string
|
||||
if err := json.Unmarshal(data, &tmp); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, v := range tmp {
|
||||
(*a)[v] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// StringSliceVal is a Value encapsulating a slice of comma-separated strings
|
||||
type StringSliceVal []string
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue