// UnmarshalYAML implements the Unmarshaller interface.
774506
func (n *Networks) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var sliceType []interface{}
	if err := unmarshal(&sliceType); err == nil {
		n.Networks = []*Network{}
		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)
			}
			n.Networks = append(n.Networks, &Network{
				Name: name,
			})
		}
		return nil
	}

	var mapType map[interface{}]interface{}
	if err := unmarshal(&mapType); err == nil {
		n.Networks = []*Network{}
		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)
			}
			network, err := handleNetwork(name, mapValue)
			if err != nil {
				return err
			}
			n.Networks = append(n.Networks, network)
		}
		return nil
	}

	return errors.New("Failed to unmarshal Networks")
}
1227981
func (s *MapEqualSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
	s.parts = map[string]string{}
	err := unmarshal(&s.parts)
	if err == nil {
		return nil
	}

	var slice []string
	err = unmarshal(&slice)
	if err != nil {
		return err
	}
	for _, v := range slice {
		parts := strings.SplitN(v, "=", 2)
		if len(parts) == 2 {
			key := parts[0]
			val := parts[1]
			s.parts[key] = val
		}
	}
	return nil
}
1265116
func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var s string
	if err := unmarshal(&s); err != nil {
		return err
	}

	urlp, err := url.Parse(s)
	if err != nil {
		return err
	}
	u.URL = urlp
	return nil
}
788238
func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
	type plain Secret
	return unmarshal((*plain)(s))
}
326402
func (u *Ulimits) UnmarshalYAML(unmarshal func(interface{}) error) error {
	ulimits := make(map[string]Ulimit)

	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 int:
				soft = int64(mv)
				hard = int64(mv)
			case map[interface{}]interface{}:
				if len(mv) != 2 {
					return fmt.Errorf("Failed to unmarshal Ulimit: %#v", mapValue)
				}
				for mkey, mvalue := range mv {
					switch mkey {
					case "soft":
						soft = int64(mvalue.(int))
					case "hard":
						hard = int64(mvalue.(int))
					default:
						// FIXME(vdemeester) Should we ignore or fail ?
						continue
					}
				}
			default:
				return fmt.Errorf("Failed to unmarshal Ulimit: %v, %T", mapValue, mapValue)
			}
			ulimits[name] = Ulimit{
				Name: name,
				ulimitValues: ulimitValues{
					Soft: soft,
					Hard: hard,
				},
			}
		}
		keys := make([]string, 0, len(ulimits))
		for key := range ulimits {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		for _, key := range keys {
			u.Elements = append(u.Elements, ulimits[key])
		}
		return nil
	}

	return errors.New("Failed to unmarshal Ulimit")
}
999308
func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var s string
	if err := unmarshal(&s); err != nil {
		return err
	}
	dur, err := ParseDuration(s)
	if err != nil {
		return err
	}
	*d = dur
	return nil
}
394327
func (a *BasicAuth) UnmarshalYAML(unmarshal func(interface{}) error) error {
	type plain BasicAuth
	return unmarshal((*plain)(a))
}
633948
func (rs *RoundStateSimple) Unmarshal(bs []byte) error {
	return cdc.UnmarshalBinaryBare(bs, rs)
}
113471
func (r Response) Unmarshal(v interface{}) error {
	if r.err != nil {
		return r.err
	}
	return json.Unmarshal(r.body, v)
}
310208
func (*yamlMarshaller) Unmarshal(data []byte, v interface{}) error {
	return yaml.Unmarshal(data, v)
}
171110
func (r *regions) UnmarshalYAML(f func(interface{}) error) error {
	if err := f(&r.Map); err != nil {
		return err
	}
	return f(&r.Slice)
}
788161
func (d *decodeState) unmarshalLiteral(data Slice, v reflect.Value) {
	d.literalStore(data, v, false)
}
1371860
func (n *networkList) UnmarshalYAML(unmarshal func(interface{}) error) error {
	slice := yaml.MapSlice{}
	err := unmarshal(&slice)
	if err != nil {
		return err
	}

	for _, s := range slice {
		nn := Network{}

		out, merr := yaml.Marshal(s.Value)
		if merr != nil {
			return merr
		}

		err = yaml.Unmarshal(out, &nn)
		if err != nil {
			return err
		}
		if nn.Name == "" {
			nn.Name = fmt.Sprintf("%v", s.Key)
		}
		if nn.Driver == "" {
			nn.Driver = "bridge"
		}
		n.networks = append(n.networks, &nn)
	}
	return err
}
538451
func (u *URL) UnmarshalYAML(umf func(interface{}) error) error {
	path := ""
	if err := umf(&path); err != nil {
		return err
	}
	um, err := ParseURL(path)
	if err != nil {
		return err
	}
	*u = *um
	return nil
}
569522
func (t *MetricSanitizationType) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var str string
	if err := unmarshal(&str); err != nil {
		return err
	}
	if str == "" {
		*t = defaultMetricSanitization
		return nil
	}
	strs := make([]string, len(validMetricSanitizationTypes))
	for _, valid := range validMetricSanitizationTypes {
		if str == valid.String() {
			*t = valid
			return nil
		}
		strs = append(strs, "'"+valid.String()+"'")
	}
	return fmt.Errorf("invalid MetricSanitizationType '%s' valid types are: %s",
		str, strings.Join(strs, ", "))
}
882421
func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var strings []string
	if err := unmarshal(&strings); err != nil {
		var str string
		if err := unmarshal(&str); err != nil {
			return err
		}
		*a = []string{str}
	} else {
		*a = strings
	}
	return nil
}
360107
func (p *StateInitializationParams) Unmarshal(data []byte) error {
	var internal stateInitializationParamsInternal
	if err := yaml.Unmarshal(data, &internal); err != nil {
		return errors.Annotate(err, "unmarshalling state initialization params")
	}
	var imageMetadata []*imagemetadata.ImageMetadata
	if err := json.Unmarshal([]byte(internal.CustomImageMetadataJSON), &imageMetadata); err != nil {
		return errors.Trace(err)
	}
	cfg, err := config.New(config.NoDefaults, internal.ControllerModelConfig)
	if err != nil {
		return errors.Trace(err)
	}
	controllerCloud, err := cloud.UnmarshalCloud([]byte(internal.ControllerCloud))
	if err != nil {
		return errors.Trace(err)
	}
	*p = StateInitializationParams{
		ControllerConfig:                        internal.ControllerConfig,
		ControllerModelConfig:                   cfg,
		ControllerModelEnvironVersion:           internal.ControllerModelEnvironVersion,
		ControllerInheritedConfig:               internal.ControllerInheritedConfig,
		RegionInheritedConfig:                   internal.RegionInheritedConfig,
		HostedModelConfig:                       internal.HostedModelConfig,
		BootstrapMachineInstanceId:              internal.BootstrapMachineInstanceId,
		BootstrapMachineConstraints:             internal.BootstrapMachineConstraints,
		BootstrapMachineHardwareCharacteristics: internal.BootstrapMachineHardwareCharacteristics,
		ModelConstraints:                        internal.ModelConstraints,
		CustomImageMetadata:                     imageMetadata,
		ControllerCloud:                         controllerCloud,
		ControllerCloudRegion:                   internal.ControllerCloudRegion,
		ControllerCloudCredentialName:           internal.ControllerCloudCredentialName,
		ControllerCloudCredential:               internal.ControllerCloudCredential,
	}
	return nil
}