// ParseYAMLWithOptions an AWS CloudFormation template (expects a []byte of valid YAML)
// Parsing can be tweaked via the specified options.
764221
func ParseYAMLWithOptions(data []byte, options *intrinsics.ProcessorOptions) (*cloudformation.Template, error) {
	// Process all AWS CloudFormation intrinsic functions (e.g. Fn::Join)
	intrinsified, err := intrinsics.ProcessYAML(data, options)
	if err != nil {
		return nil, err
	}

	return unmarshal(intrinsified)

}
80348
func ParseYAMLOrJSON(filePath string, v interface{}) (retErr error) {
	data, err := ioutil.ReadFile(filePath)
	if err != nil {
		return err
	}
	switch ext := filepath.Ext(filePath); ext {
	case ".yml", ".yaml":
		data, err = ToJSON(data, ToJSONOptions{})
		if err != nil {
			return err
		}
	case ".json":
	default:
		return fmt.Errorf("pkgyaml: %s is not a valid extension yml, yaml, or json", ext)
	}
	return json.Unmarshal(data, v)
}
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
}
834072
func (c *containerList) UnmarshalYAML(unmarshal func(interface{}) error) error {
	slice := yaml.MapSlice{}
	err := unmarshal(&slice)
	if err != nil {
		return err
	}

	for _, s := range slice {
		cc := container{}

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

		err = yaml.Unmarshal(out, &cc)
		if err != nil {
			return err
		}
		if cc.Name == "" {
			cc.Name = fmt.Sprintf("%v", s.Key)
		}
		if cc.Image == "" {
			cc.Image = fmt.Sprintf("%v", s.Key)
		}
		c.containers = append(c.containers, &Container{
			Name:           cc.Name,
			Image:          cc.Image,
			Build:          cc.Build,
			Pull:           cc.Pull,
			Privileged:     cc.Privileged,
			Environment:    cc.Environment.Map(),
			Entrypoint:     cc.Entrypoint.Slice(),
			Command:        cc.Command.Slice(),
			Commands:       cc.Commands.Slice(),
			ExtraHosts:     cc.ExtraHosts.Slice(),
			Volumes:        cc.Volumes.Slice(),
			VolumesFrom:    cc.VolumesFrom.Slice(),
			Devices:        cc.Devices.Slice(),
			Network:        cc.Network,
			DNS:            cc.DNS.Slice(),
			DNSSearch:      cc.DNSSearch.Slice(),
			MemSwapLimit:   cc.MemSwapLimit,
			MemLimit:       cc.MemLimit,
			CPUQuota:       cc.CPUQuota,
			CPUShares:      cc.CPUShares,
			CPUSet:         cc.CPUSet,
			OomKillDisable: cc.OomKillDisable,
			Vargs:          cc.Vargs,
			AuthConfig: Auth{
				Username: cc.AuthConfig.Username,
				Password: cc.AuthConfig.Password,
				Email:    cc.AuthConfig.Email,
			},
			Constraints: cc.Constraints,
		})
	}
	return err
}
1132210
func (api *API) parseOptions(opts ...Option) error {
	// Range over each options function and apply it to our API type to
	// configure it. Options functions are applied in order, with any
	// conflicting options overriding earlier calls.
	for _, option := range opts {
		err := option(api)
		if err != nil {
			return err
		}
	}

	return nil
}
126187
func (s *Strings) UnmarshalYAML(unmarshal func(interface{}) error) error {
	// try unmarshal as string
	var val string
	err := unmarshal(&val)
	if err == nil {
		*s = []string{val}
		return nil
	}

	// try unmarshal as slice
	var slice []string
	err = unmarshal(&slice)
	if err == nil {
		*s = slice
		return nil
	}

	return err
}
374499
func parseOptions(line string) map[string]string {
	options := map[string]string{}
	optionParts := strings.Split(line, ",")
	for _, option := range optionParts {
		pairs := strings.SplitN(option, "=", 2)
		switch len(pairs) {
		case 1:
			glog.V(4).Infof("option: %s", pairs[0])
			options[pairs[0]] = ""
			continue
		case 2:
			glog.V(4).Infof("option: %s  k:%s  v:%s", option, pairs[0], pairs[1])
			options[pairs[0]] = pairs[1]
			continue
		}
	}

	return options
}
277349
func parseTmpfsOptions(options string) (int, string, error) {
	flags, data := parseOptions(options)
	validFlags := map[string]bool{
		"":          true,
		"size":      true,
		"mode":      true,
		"uid":       true,
		"gid":       true,
		"nr_inodes": true,
		"nr_blocks": true,
		"mpol":      true,
	}
	for _, o := range strings.Split(data, ",") {
		opt := strings.SplitN(o, "=", 2)
		if !validFlags[opt[0]] {
			return 0, "", fmt.Errorf("Invalid tmpfs option %q", opt)
		}
	}
	return flags, data, nil
}
1338674
func (o *Options) HashOptions() string {
	hasher := sha1.New()

	hasher.Write([]byte(o.CTags))
	hasher.Write([]byte(fmt.Sprintf("%t", o.CTagsMustSucceed)))
	hasher.Write([]byte(fmt.Sprintf("%d", o.SizeMax)))
	hasher.Write([]byte(fmt.Sprintf("%q", o.LargeFiles)))

	return fmt.Sprintf("%x", hasher.Sum(nil))
}
311376
func ParseRawYaml(data []byte, dest interface{}) error {

	// Yaml can't parse empty strings
	configString := string(data)
	configString = strings.TrimSpace(configString)

	if configString != "" {
		err := utils.YamlUnmarshal([]byte(configString), dest)
		if err != nil {
			return fmt.Errorf("error parsing configuration: %v", err)
		}
	}

	return nil
}
880477
func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
	type plain HTTPClientConfig
	if err := unmarshal((*plain)(c)); err != nil {
		return err
	}
	return c.Validate()
}
273979
func (s *SliceorMap) UnmarshalYAML(unmarshal func(interface{}) error) error {

	var sliceType []interface{}
	if err := unmarshal(&sliceType); err == nil {
		parts := map[string]string{}
		for _, s := range sliceType {
			if str, ok := s.(string); ok {
				str := strings.TrimSpace(str)
				keyValueSlice := strings.SplitN(str, "=", 2)

				key := keyValueSlice[0]
				val := ""
				if len(keyValueSlice) == 2 {
					val = keyValueSlice[1]
				}
				parts[key] = val
			} else {
				return fmt.Errorf("Cannot unmarshal '%v' of type %T into a string value", s, s)
			}
		}
		*s = parts
		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")
}
908026
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
		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")
}
925498
func parseSerializationOpts(inp string, validKeys []string, validAbbrKeys map[string]string) (map[string]string, *probe.Error) {
	if validAbbrKeys == nil {
		validAbbrKeys = make(map[string]string)
	}
	validKeyFn := func(key string, validKeys []string) bool {
		for _, name := range validKeys {
			if strings.ToLower(name) == strings.ToLower(key) {
				return true
			}
		}
		return false
	}
	kv, err := parseKVArgs(inp)
	if err != nil {
		return nil, err
	}
	ikv := make(map[string]string)
	for k, v := range kv {
		fldName, ok := validAbbrKeys[strings.ToLower(k)]
		if ok {
			ikv[strings.ToLower(fldName)] = v
		} else {
			ikv[strings.ToLower(k)] = v
		}
	}
	for k := range ikv {
		if !validKeyFn(k, validKeys) {
			return nil, probe.NewError(errors.New("Options should be key-value pairs in the form key=value,... where valid key(s) are " + fmtString(validAbbrKeys, validKeys)))
		}
	}
	return ikv, nil
}
1321683
func (auth *Auth) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var m map[string]Parameters
	err := unmarshal(&m)
	if err == nil {
		if len(m) > 1 {
			types := make([]string, 0, len(m))
			for k := range m {
				types = append(types, k)
			}

			// TODO(stevvooe): May want to change this slightly for
			// authorization to allow multiple challenges.
			return fmt.Errorf("must provide exactly one type. Provided: %v", types)

		}
		*auth = m
		return nil
	}

	var authType string
	err = unmarshal(&authType)
	if err == nil {
		*auth = Auth{authType: Parameters{}}
		return nil
	}

	return err
}
900274
func (s *MaporEqualSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
	parts, err := unmarshalToStringOrSepMapParts(unmarshal, "=")
	if err != nil {
		return err
	}
	*s = parts
	return nil
}
1273552
func (c *Compiler) CompileWithTemplate(t *template.Template) (*template.Template, error) {
	data, err := c.CompileString()

	if err != nil {
		return nil, err
	}

	tpl, err := t.Funcs(FuncMap).Parse(data)

	if err != nil {
		return nil, err
	}

	return tpl, nil
}