bump(github.com/docker/libcompose) v0.3.0
This commit is contained in:
+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) {
|
||||
|
||||
Reference in New Issue
Block a user