mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-05 16:39:50 +00:00
28 lines
559 B
Go
28 lines
559 B
Go
package yaml
|
|
|
|
// 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
|
|
}
|