traefik/integration/vendor/github.com/docker/libcompose/yaml/command.go

33 lines
672 B
Go
Raw Normal View History

2017-02-07 21:33:23 +00:00
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
}