2016-04-19 20:02:28 +00:00
|
|
|
package yaml
|
2016-04-11 18:15:53 +00:00
|
|
|
|
|
|
|
// stringOrSlice represents a string or an array of strings.
|
|
|
|
type stringOrSlice struct {
|
|
|
|
parts []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *stringOrSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
|
|
var sliceType []string
|
|
|
|
err := unmarshal(&sliceType)
|
|
|
|
if err == nil {
|
|
|
|
s.parts = sliceType
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var stringType string
|
|
|
|
err = unmarshal(&stringType)
|
|
|
|
if err == nil {
|
|
|
|
sliceType = make([]string, 0, 1)
|
|
|
|
s.parts = append(sliceType, string(stringType))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s stringOrSlice) Slice() []string {
|
|
|
|
return s.parts
|
|
|
|
}
|