// MarshalYAML returns the object to marshal to the YAML representation of the
// version.
325296
func (v *VersionInfo) MarshalYAML() (interface{}, error) {

	return &struct {
		SemVer         string `yaml:"semver"`
		ShaLong        string `yaml:"shaLong"`
		BuildTimestamp int64  `yaml:"buildTimestamp"`
		Branch         string `yaml:"branch"`
		Arch           string `yaml:"arch"`
	}{
		SemVer:         v.SemVer,
		ShaLong:        v.ShaLong,
		BuildTimestamp: v.BuildTimestamp.Unix(),
		Branch:         v.Branch,
		Arch:           v.Arch,
	}, nil
}
178212
func ToYAML(s string) (string, error) {
	m, err := Parse(s)
	if err != nil {
		return "", err
	}
	d, err := yaml.Marshal(m)
	return string(d), err
}
1290080
func ToVersionedYaml(obj runtime.Object) ([]byte, error) {
	var w bytes.Buffer
	err := encoder().Encode(obj, &w)
	if err != nil {
		return nil, fmt.Errorf("error encoding %T: %v", obj, err)
	}
	return w.Bytes(), nil
}
1184019
func (e External) MarshalYAML() (interface{}, error) {
	if e.Name == "" {
		return e.External, nil
	}
	return External{Name: e.Name}, nil
}
709625
func (s *Secret) decodeYAML() (bool, error) {
	if !strings.HasPrefix(s.body, "---\n") && s.password != "---" {
		return false, nil
	}
	d := make(map[string]interface{})
	err := yaml.Unmarshal([]byte(s.body), &d)
	if err != nil {
		return true, err
	}
	s.data = d
	return true, nil
}
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
}
239381
func (mmap MarshalMap) Bool(key string) (bool, error) {
	val, exists := mmap.Value(key)
	if !exists {
		return false, fmt.Errorf(`"%s" is not set`, key)
	}

	boolValue, isBool := val.(bool)
	if !isBool {
		return false, fmt.Errorf(`"%s" is expected to be a boolean`, key)
	}
	return boolValue, nil
}
223310
func ValidateYAML(r io.Reader) (map[interface{}]interface{}, error) {
	b, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}
	m := map[interface{}]interface{}{}
	if err := yaml.Unmarshal(b, &m); err != nil {
		return nil, err
	}
	return m, nil
}
876906
func (h *HLL) MarshalBinary() ([]byte, error) {
	var buf bytes.Buffer
	ts := h.tempSet
	if ts == nil {
		ts = &tempSet{}
	}
	sl := h.sparseList
	if sl == nil {
		sl = &sparseList{}
	}
	err := gob.NewEncoder(&buf).Encode(
		serializable{
			P:          h.P,
			M1:         h.m1,
			M2:         h.m2,
			Alpha:      h.alpha,
			Format:     h.format,
			TempSet:    *ts,
			SparseList: *sl,
			Registers:  h.registers,
		})
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
733166
func MarshalBuild(b chronograf.BuildInfo) ([]byte, error) {
	return proto.Marshal(&BuildInfo{
		Version: b.Version,
		Commit:  b.Commit,
	})
}
837996
func (i *InstanceID) MarshalYAML() (interface{}, error) {

	var metadata map[string]interface{}
	if len(i.metadata) > 0 {
		if err := json.Unmarshal(i.metadata, &metadata); err != nil {
			return nil, err
		}
	}

	return &struct {
		ID       string                 `yaml:"id"`
		Driver   string                 `yaml:"driver"`
		Service  string                 `yaml:"service"`
		Fields   map[string]string      `yaml:"fields,omitempty"`
		Metadata map[string]interface{} `yaml:"metadata,omitempty"`
	}{i.ID, i.Driver, i.Service, i.Fields, metadata}, nil
}
843513
func marshalMany(models []interface{}) (*ManyPayload, error) {
	payload := &ManyPayload{
		Data: []*Node{},
	}
	included := map[string]*Node{}

	for _, model := range models {
		node, err := visitModelNode(model, &included, true)
		if err != nil {
			return nil, err
		}
		payload.Data = append(payload.Data, node)
	}
	payload.Included = nodeMapValues(&included)

	return payload, nil
}
891747
func (b Build) MarshalYAML() (interface{}, error) {
	m := map[string]interface{}{}
	if b.Context != "" {
		m["context"] = b.Context
	}
	if b.Dockerfile != "" {
		m["dockerfile"] = b.Dockerfile
	}
	if len(b.Args) > 0 {
		m["args"] = b.Args
	}
	if len(b.CacheFrom) > 0 {
		m["cache_from"] = b.CacheFrom
	}
	if len(b.Labels) > 0 {
		m["labels"] = b.Labels
	}
	if b.Target != "" {
		m["target"] = b.Target
	}
	if b.Network != "" {
		m["network"] = b.Network
	}
	return m, nil
}
181603
func (c *Configurator) LoadConfigFromYAML(serviceName string, r io.Reader) (yarpc.Config, error) {
	b, err := ioutil.ReadAll(r)
	if err != nil {
		return yarpc.Config{}, err
	}

	var data map[string]interface{}
	if err := yaml.Unmarshal(b, &data); err != nil {
		return yarpc.Config{}, err
	}
	return c.LoadConfig(serviceName, data)
}
553411
func MarshalToYamlForCodecs(obj runtime.Object, gv schema.GroupVersion, codecs serializer.CodecFactory) ([]byte, error) {
	const mediaType = runtime.ContentTypeYAML
	info, ok := runtime.SerializerInfoForMediaType(codecs.SupportedMediaTypes(), mediaType)
	if !ok {
		return []byte{}, errors.Errorf("unsupported media type %q", mediaType)
	}

	encoder := codecs.EncoderForVersion(info.Serializer, gv)
	return runtime.Encode(encoder, obj)
}
504045
func (s Services) MarshalJSON() ([]byte, error) {
	data, err := s.MarshalYAML()
	if err != nil {
		return nil, err
	}
	return json.MarshalIndent(data, "", "  ")
}
1339717
func MarshalCloud(cloud Cloud) ([]byte, error) {
	return yaml.Marshal(cloudToInternal(cloud, true))
}