forked from LaconicNetwork/kompose
bump(github.com/docker/libcompose) v0.3.0
This commit is contained in:
+18
-11
@@ -1,6 +1,7 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -15,7 +16,7 @@ type Build struct {
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
func (b Build) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
func (b Build) MarshalYAML() (interface{}, error) {
|
||||
m := map[string]interface{}{}
|
||||
if b.Context != "" {
|
||||
m["context"] = b.Context
|
||||
@@ -26,16 +27,20 @@ func (b Build) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
if len(b.Args) > 0 {
|
||||
m["args"] = b.Args
|
||||
}
|
||||
return "", m, nil
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (b *Build) UnmarshalYAML(tag string, value interface{}) error {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
b.Context = v
|
||||
case map[interface{}]interface{}:
|
||||
for mapKey, mapValue := range v {
|
||||
func (b *Build) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err == nil {
|
||||
b.Context = stringType
|
||||
return nil
|
||||
}
|
||||
|
||||
var mapType map[interface{}]interface{}
|
||||
if err := unmarshal(&mapType); err == nil {
|
||||
for mapKey, mapValue := range mapType {
|
||||
switch mapKey {
|
||||
case "context":
|
||||
b.Context = mapValue.(string)
|
||||
@@ -52,10 +57,10 @@ func (b *Build) UnmarshalYAML(tag string, value interface{}) error {
|
||||
continue
|
||||
}
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal Build: %#v", value)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
return errors.New("Failed to unmarshal Build")
|
||||
}
|
||||
|
||||
func handleBuildArgs(value interface{}) (map[string]string, error) {
|
||||
@@ -98,6 +103,8 @@ func handleBuildArgMap(m map[interface{}]interface{}) (map[string]string, error)
|
||||
switch a := mapValue.(type) {
|
||||
case string:
|
||||
argValue = a
|
||||
case int:
|
||||
argValue = strconv.Itoa(a)
|
||||
case int64:
|
||||
argValue = strconv.Itoa(int(a))
|
||||
default:
|
||||
|
||||
+23
-13
@@ -1,6 +1,7 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/engine-api/types/strslice"
|
||||
@@ -11,22 +12,31 @@ import (
|
||||
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)
|
||||
func (s *Command) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err == nil {
|
||||
parts, err := shlex.Split(stringType)
|
||||
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
|
||||
}
|
||||
return nil
|
||||
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
parts, err := toStrings(sliceType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*s = parts
|
||||
return nil
|
||||
}
|
||||
|
||||
var interfaceType interface{}
|
||||
if err := unmarshal(&interfaceType); err == nil {
|
||||
fmt.Println(interfaceType)
|
||||
}
|
||||
|
||||
return errors.New("Failed to unmarshal Command")
|
||||
}
|
||||
|
||||
+17
-24
@@ -1,9 +1,5 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// External represents an external network entry in compose file.
|
||||
// It can be a boolean (true|false) or have a name
|
||||
type External struct {
|
||||
@@ -12,33 +8,30 @@ type External struct {
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
func (n External) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
func (n External) MarshalYAML() (interface{}, error) {
|
||||
if n.Name == "" {
|
||||
return "", n.External, nil
|
||||
return n.External, nil
|
||||
}
|
||||
return "", map[string]interface{}{
|
||||
return map[string]interface{}{
|
||||
"name": n.Name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (n *External) UnmarshalYAML(tag string, value interface{}) error {
|
||||
switch v := value.(type) {
|
||||
case bool:
|
||||
n.External = v
|
||||
case map[interface{}]interface{}:
|
||||
for mapKey, mapValue := range v {
|
||||
switch mapKey {
|
||||
case "name":
|
||||
n.Name = mapValue.(string)
|
||||
default:
|
||||
// Ignore unknown keys
|
||||
continue
|
||||
}
|
||||
}
|
||||
n.External = true
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal External: %#v", value)
|
||||
func (n *External) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
if err := unmarshal(&n.External); err == nil {
|
||||
return nil
|
||||
}
|
||||
var dummyExternal struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
err := unmarshal(&dummyExternal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n.Name = dummyExternal.Name
|
||||
n.External = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+16
-11
@@ -1,6 +1,7 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -20,20 +21,20 @@ type Network struct {
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
func (n Networks) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
func (n Networks) MarshalYAML() (interface{}, error) {
|
||||
m := map[string]*Network{}
|
||||
for _, network := range n.Networks {
|
||||
m[network.Name] = network
|
||||
}
|
||||
return "", m, nil
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (n *Networks) UnmarshalYAML(tag string, value interface{}) error {
|
||||
switch v := value.(type) {
|
||||
case []interface{}:
|
||||
func (n *Networks) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
n.Networks = []*Network{}
|
||||
for _, network := range v {
|
||||
for _, network := range sliceType {
|
||||
name, ok := network.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", name, name)
|
||||
@@ -42,9 +43,13 @@ func (n *Networks) UnmarshalYAML(tag string, value interface{}) error {
|
||||
Name: name,
|
||||
})
|
||||
}
|
||||
case map[interface{}]interface{}:
|
||||
return nil
|
||||
}
|
||||
|
||||
var mapType map[interface{}]interface{}
|
||||
if err := unmarshal(&mapType); err == nil {
|
||||
n.Networks = []*Network{}
|
||||
for mapKey, mapValue := range v {
|
||||
for mapKey, mapValue := range mapType {
|
||||
name, ok := mapKey.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", name, name)
|
||||
@@ -55,10 +60,10 @@ func (n *Networks) UnmarshalYAML(tag string, value interface{}) error {
|
||||
}
|
||||
n.Networks = append(n.Networks, network)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal Networks: %#v", value)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
return errors.New("Failed to unmarshal Networks")
|
||||
}
|
||||
|
||||
func handleNetwork(name string, value interface{}) (*Network, error) {
|
||||
|
||||
+83
-46
@@ -1,6 +1,7 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -8,50 +9,65 @@ import (
|
||||
"github.com/docker/engine-api/types/strslice"
|
||||
)
|
||||
|
||||
// Stringorslice represents a string or an array of strings.
|
||||
// Using engine-api Strslice and augment it with YAML marshalling stuff.
|
||||
// StringorInt represents a string or an integer.
|
||||
type StringorInt int64
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *StringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var intType int64
|
||||
if err := unmarshal(&intType); err == nil {
|
||||
*s = StringorInt(intType)
|
||||
return nil
|
||||
}
|
||||
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err == nil {
|
||||
intType, err := strconv.ParseInt(stringType, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*s = StringorInt(intType)
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("Failed to unmarshal StringorInt")
|
||||
}
|
||||
|
||||
// Stringorslice represents
|
||||
// Using engine-api Strslice and augment it with YAML marshalling stuff. a string or an array of strings.
|
||||
type Stringorslice strslice.StrSlice
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *Stringorslice) UnmarshalYAML(tag string, value interface{}) error {
|
||||
switch value := value.(type) {
|
||||
case []interface{}:
|
||||
parts, err := toStrings(value)
|
||||
func (s *Stringorslice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err == nil {
|
||||
*s = []string{stringType}
|
||||
return nil
|
||||
}
|
||||
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
parts, err := toStrings(sliceType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*s = parts
|
||||
case string:
|
||||
*s = []string{value}
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal Stringorslice: %#v", value)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
return errors.New("Failed to unmarshal Stringorslice")
|
||||
}
|
||||
|
||||
// SliceorMap represents a slice or a map of strings.
|
||||
type SliceorMap map[string]string
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *SliceorMap) UnmarshalYAML(tag string, value interface{}) error {
|
||||
switch value := value.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
func (s *SliceorMap) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
parts := map[string]string{}
|
||||
for k, v := range value {
|
||||
if sk, ok := k.(string); ok {
|
||||
if sv, ok := v.(string); ok {
|
||||
parts[sk] = sv
|
||||
} else {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' of type %T into a string value", v, v)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' of type %T into a string value", k, k)
|
||||
}
|
||||
}
|
||||
*s = parts
|
||||
case []interface{}:
|
||||
parts := map[string]string{}
|
||||
for _, s := range value {
|
||||
for _, s := range sliceType {
|
||||
if str, ok := s.(string); ok {
|
||||
str := strings.TrimSpace(str)
|
||||
keyValueSlice := strings.SplitN(str, "=", 2)
|
||||
@@ -67,10 +83,28 @@ func (s *SliceorMap) UnmarshalYAML(tag string, value interface{}) error {
|
||||
}
|
||||
}
|
||||
*s = parts
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal SliceorMap: %#v", value)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
var mapType map[interface{}]interface{}
|
||||
if err := unmarshal(&mapType); err == nil {
|
||||
parts := map[string]string{}
|
||||
for k, v := range mapType {
|
||||
if sk, ok := k.(string); ok {
|
||||
if sv, ok := v.(string); ok {
|
||||
parts[sk] = sv
|
||||
} else {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' of type %T into a string value", v, v)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' of type %T into a string value", k, k)
|
||||
}
|
||||
}
|
||||
*s = parts
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("Failed to unmarshal SliceorMap")
|
||||
}
|
||||
|
||||
// MaporEqualSlice represents a slice of strings that gets unmarshal from a
|
||||
@@ -78,8 +112,8 @@ func (s *SliceorMap) UnmarshalYAML(tag string, value interface{}) error {
|
||||
type MaporEqualSlice []string
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *MaporEqualSlice) UnmarshalYAML(tag string, value interface{}) error {
|
||||
parts, err := unmarshalToStringOrSepMapParts(value, "=")
|
||||
func (s *MaporEqualSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
parts, err := unmarshalToStringOrSepMapParts(unmarshal, "=")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -97,8 +131,8 @@ func (s *MaporEqualSlice) ToMap() map[string]string {
|
||||
type MaporColonSlice []string
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *MaporColonSlice) UnmarshalYAML(tag string, value interface{}) error {
|
||||
parts, err := unmarshalToStringOrSepMapParts(value, ":")
|
||||
func (s *MaporColonSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
parts, err := unmarshalToStringOrSepMapParts(unmarshal, ":")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -116,8 +150,8 @@ func (s *MaporColonSlice) ToMap() map[string]string {
|
||||
type MaporSpaceSlice []string
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *MaporSpaceSlice) UnmarshalYAML(tag string, value interface{}) error {
|
||||
parts, err := unmarshalToStringOrSepMapParts(value, " ")
|
||||
func (s *MaporSpaceSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
parts, err := unmarshalToStringOrSepMapParts(unmarshal, " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -130,15 +164,16 @@ func (s *MaporSpaceSlice) ToMap() map[string]string {
|
||||
return toMap(*s, " ")
|
||||
}
|
||||
|
||||
func unmarshalToStringOrSepMapParts(value interface{}, key string) ([]string, error) {
|
||||
switch value := value.(type) {
|
||||
case []interface{}:
|
||||
return toStrings(value)
|
||||
case map[interface{}]interface{}:
|
||||
return toSepMapParts(value, key)
|
||||
default:
|
||||
return nil, fmt.Errorf("Failed to unmarshal Map or Slice: %#v", value)
|
||||
func unmarshalToStringOrSepMapParts(unmarshal func(interface{}) error, key string) ([]string, error) {
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
return toStrings(sliceType)
|
||||
}
|
||||
var mapType map[interface{}]interface{}
|
||||
if err := unmarshal(&mapType); err == nil {
|
||||
return toSepMapParts(mapType, key)
|
||||
}
|
||||
return nil, errors.New("Failed to unmarshal MaporSlice")
|
||||
}
|
||||
|
||||
func toSepMapParts(value map[interface{}]interface{}, sep string) ([]string, error) {
|
||||
@@ -150,6 +185,8 @@ func toSepMapParts(value map[interface{}]interface{}, sep string) ([]string, err
|
||||
if sk, ok := k.(string); ok {
|
||||
if sv, ok := v.(string); ok {
|
||||
parts = append(parts, sk+sep+sv)
|
||||
} else if sv, ok := v.(int); ok {
|
||||
parts = append(parts, sk+sep+strconv.Itoa(sv))
|
||||
} else if sv, ok := v.(int64); ok {
|
||||
parts = append(parts, sk+sep+strconv.FormatInt(sv, 10))
|
||||
} else if v == nil {
|
||||
|
||||
+19
-17
@@ -1,6 +1,7 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
@@ -12,29 +13,30 @@ type Ulimits struct {
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
func (u Ulimits) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
func (u Ulimits) MarshalYAML() (interface{}, error) {
|
||||
ulimitMap := make(map[string]Ulimit)
|
||||
for _, ulimit := range u.Elements {
|
||||
ulimitMap[ulimit.Name] = ulimit
|
||||
}
|
||||
return "", ulimitMap, nil
|
||||
return ulimitMap, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (u *Ulimits) UnmarshalYAML(tag string, value interface{}) error {
|
||||
func (u *Ulimits) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
ulimits := make(map[string]Ulimit)
|
||||
switch v := value.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
for mapKey, mapValue := range v {
|
||||
|
||||
var mapType map[interface{}]interface{}
|
||||
if err := unmarshal(&mapType); err == nil {
|
||||
for mapKey, mapValue := range mapType {
|
||||
name, ok := mapKey.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", name, name)
|
||||
}
|
||||
var soft, hard int64
|
||||
switch mv := mapValue.(type) {
|
||||
case int64:
|
||||
soft = mv
|
||||
hard = mv
|
||||
case int:
|
||||
soft = int64(mv)
|
||||
hard = int64(mv)
|
||||
case map[interface{}]interface{}:
|
||||
if len(mv) != 2 {
|
||||
return fmt.Errorf("Failed to unmarshal Ulimit: %#v", mapValue)
|
||||
@@ -42,9 +44,9 @@ func (u *Ulimits) UnmarshalYAML(tag string, value interface{}) error {
|
||||
for mkey, mvalue := range mv {
|
||||
switch mkey {
|
||||
case "soft":
|
||||
soft = mvalue.(int64)
|
||||
soft = int64(mvalue.(int))
|
||||
case "hard":
|
||||
hard = mvalue.(int64)
|
||||
hard = int64(mvalue.(int))
|
||||
default:
|
||||
// FIXME(vdemeester) Should we ignore or fail ?
|
||||
continue
|
||||
@@ -69,10 +71,10 @@ func (u *Ulimits) UnmarshalYAML(tag string, value interface{}) error {
|
||||
for _, key := range keys {
|
||||
u.Elements = append(u.Elements, ulimits[key])
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal Ulimit: %#v", value)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
return errors.New("Failed to unmarshal Ulimit")
|
||||
}
|
||||
|
||||
// Ulimit represents ulimit information.
|
||||
@@ -87,11 +89,11 @@ type ulimitValues struct {
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
func (u Ulimit) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
func (u Ulimit) MarshalYAML() (interface{}, error) {
|
||||
if u.Soft == u.Hard {
|
||||
return "", u.Soft, nil
|
||||
return u.Soft, nil
|
||||
}
|
||||
return "", u.ulimitValues, err
|
||||
return u.ulimitValues, nil
|
||||
}
|
||||
|
||||
// NewUlimit creates a Ulimit based on the specified parts.
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Volumes represents a list of service volumes in compose file.
|
||||
// It has several representation, hence this specific struct.
|
||||
type Volumes struct {
|
||||
Volumes []*Volume
|
||||
}
|
||||
|
||||
// Volume represent a service volume
|
||||
type Volume struct {
|
||||
Source string `yaml:"-"`
|
||||
Destination string `yaml:"-"`
|
||||
AccessMode string `yaml:"-"`
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (v *Volume) String() string {
|
||||
var paths []string
|
||||
if v.Source != "" {
|
||||
paths = []string{v.Source, v.Destination}
|
||||
} else {
|
||||
paths = []string{v.Destination}
|
||||
}
|
||||
if v.AccessMode != "" {
|
||||
paths = append(paths, v.AccessMode)
|
||||
}
|
||||
return strings.Join(paths, ":")
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
func (v Volumes) MarshalYAML() (interface{}, error) {
|
||||
vs := []string{}
|
||||
for _, volume := range v.Volumes {
|
||||
vs = append(vs, volume.String())
|
||||
}
|
||||
return vs, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (v *Volumes) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
v.Volumes = []*Volume{}
|
||||
for _, volume := range sliceType {
|
||||
name, ok := volume.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", name, name)
|
||||
}
|
||||
elts := strings.SplitN(name, ":", 3)
|
||||
var vol *Volume
|
||||
switch {
|
||||
case len(elts) == 1:
|
||||
vol = &Volume{
|
||||
Destination: elts[0],
|
||||
}
|
||||
case len(elts) == 2:
|
||||
vol = &Volume{
|
||||
Source: elts[0],
|
||||
Destination: elts[1],
|
||||
}
|
||||
case len(elts) == 3:
|
||||
vol = &Volume{
|
||||
Source: elts[0],
|
||||
Destination: elts[1],
|
||||
AccessMode: elts[2],
|
||||
}
|
||||
default:
|
||||
// FIXME
|
||||
return fmt.Errorf("")
|
||||
}
|
||||
v.Volumes = append(v.Volumes, vol)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("Failed to unmarshal Volumes")
|
||||
}
|
||||
Reference in New Issue
Block a user