traefik/integration/vendor/github.com/docker/libcompose/yaml/command.go
2017-03-09 13:13:03 +01:00

32 lines
672 B
Go

package yaml
import (
"fmt"
"github.com/docker/engine-api/types/strslice"
"github.com/flynn/go-shlex"
)
// Command represents a docker command, can be a string or an array of strings.
type Command strslice.StrSlice
// UnmarshalYAML implements the Unmarshaller interface.
func (s *Command) UnmarshalYAML(tag string, value interface{}) error {
switch value := value.(type) {
case []interface{}:
parts, err := toStrings(value)
if err != nil {
return err
}
*s = parts
case string:
parts, err := shlex.Split(value)
if err != nil {
return err
}
*s = parts
default:
return fmt.Errorf("Failed to unmarshal Command: %#v", value)
}
return nil
}