1
0
Fork 0
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:
Kubernetes Prow Robot 2023-03-15 01:44:15 -07:00 committed by GitHub
commit 6688a2f232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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