// YAML marshals the "v" using the yaml marshaler and renders its result to the client.
5097
func (ctx *context) YAML(v interface{}) (int, error) {
	out, err := yaml.Marshal(v)
	if err != nil {
		ctx.StatusCode(http.StatusInternalServerError)
		return 0, err
	}

	ctx.ContentType(ContentYAMLHeaderValue)
	return ctx.Write(out)
}
1184019
func (e External) MarshalYAML() (interface{}, error) {
	if e.Name == "" {
		return e.External, nil
	}
	return External{Name: e.Name}, nil
}
310208
func (*yamlMarshaller) Unmarshal(data []byte, v interface{}) error {
	return yaml.Unmarshal(data, v)
}
204886
func (d *FileDescriptor) VarName() string {
	h := sha256.Sum256([]byte(d.GetName()))
	return fmt.Sprintf("fileDescriptor_%s", hex.EncodeToString(h[:8]))
}
1758
func (h *Host) MarshalAnsible() map[string]interface{} {
	var vStr []map[string]interface{}
	if len(h.Vars) > 0 {
		for i := range h.Vars {
			vStr = append(vStr, h.Vars[i].MarshalAnsible())
		}
		return map[string]interface{}{h.Name: map[string]interface{}{"vars": vStr}}
	}
	return map[string]interface{}{h.Name: ""}
}
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
}
619890
func ToJSON(data []byte) ([]byte, error) {
	if hasJSONPrefix(data) {
		return data, nil
	}
	return yaml.YAMLToJSON(data)
}
1034029
func (r YAML) Render(w http.ResponseWriter) error {
	r.WriteContentType(w)

	bytes, err := yaml.Marshal(r.Data)
	if err != nil {
		return err
	}

	_, err = w.Write(bytes)
	return err
}
1363443
func (l *yamlLoader) Load(out interface{}) error {
	var buf bytes.Buffer
	buf.ReadFrom(l.r)
	if err := yaml.Unmarshal(buf.Bytes(), out); err != nil {
		return err
	}
	return nil
}
767295
func (v Values) Encode(w io.Writer) error {
	//return yaml.NewEncoder(w).Encode(v)
	out, err := yaml.Marshal(v)
	if err != nil {
		return err
	}
	_, err = w.Write(out)
	return err
}
1134725
func (ya YAxis) Render(r Renderer, canvasBox Box, ra Range, defaults Style, ticks []Tick) {
	tickStyle := ya.TickStyle.InheritFrom(ya.Style.InheritFrom(defaults))
	tickStyle.WriteToRenderer(r)

	sw := tickStyle.GetStrokeWidth(defaults.StrokeWidth)

	var lx int
	var tx int
	if ya.AxisType == YAxisPrimary {
		lx = canvasBox.Right + int(sw)
		tx = lx + DefaultYAxisMargin
	} else if ya.AxisType == YAxisSecondary {
		lx = canvasBox.Left - int(sw)
		tx = lx - DefaultYAxisMargin
	}

	r.MoveTo(lx, canvasBox.Bottom)
	r.LineTo(lx, canvasBox.Top)
	r.Stroke()

	var maxTextWidth int
	var finalTextX, finalTextY int
	for _, t := range ticks {
		v := t.Value
		ly := canvasBox.Bottom - ra.Translate(v)

		tb := Draw.MeasureText(r, t.Label, tickStyle)

		if tb.Width() > maxTextWidth {
			maxTextWidth = tb.Width()
		}

		if ya.AxisType == YAxisSecondary {
			finalTextX = tx - tb.Width()
		} else {
			finalTextX = tx
		}

		if tickStyle.TextRotationDegrees == 0 {
			finalTextY = ly + tb.Height()>>1
		} else {
			finalTextY = ly
		}

		tickStyle.WriteToRenderer(r)

		r.MoveTo(lx, ly)
		if ya.AxisType == YAxisPrimary {
			r.LineTo(lx+DefaultHorizontalTickWidth, ly)
		} else if ya.AxisType == YAxisSecondary {
			r.LineTo(lx-DefaultHorizontalTickWidth, ly)
		}
		r.Stroke()

		Draw.Text(r, t.Label, finalTextX, finalTextY, tickStyle)
	}

	nameStyle := ya.NameStyle.InheritFrom(defaults.InheritFrom(Style{TextRotationDegrees: 90}))
	if ya.NameStyle.Show && len(ya.Name) > 0 {
		nameStyle.GetTextOptions().WriteToRenderer(r)
		tb := Draw.MeasureText(r, ya.Name, nameStyle)

		var tx int
		if ya.AxisType == YAxisPrimary {
			tx = canvasBox.Right + int(sw) + DefaultYAxisMargin + maxTextWidth + DefaultYAxisMargin
		} else if ya.AxisType == YAxisSecondary {
			tx = canvasBox.Left - (DefaultYAxisMargin + int(sw) + maxTextWidth + DefaultYAxisMargin)
		}

		var ty int
		if nameStyle.TextRotationDegrees == 0 {
			ty = canvasBox.Top + (canvasBox.Height()>>1 - tb.Width()>>1)
		} else {
			ty = canvasBox.Top + (canvasBox.Height()>>1 - tb.Height()>>1)
		}

		Draw.Text(r, ya.Name, tx, ty, nameStyle)
	}

	if ya.Zero.Style.Show {
		ya.Zero.Render(r, canvasBox, ra, false, Style{})
	}

	if ya.GridMajorStyle.Show || ya.GridMinorStyle.Show {
		for _, gl := range ya.GetGridLines(ticks) {
			if (gl.IsMinor && ya.GridMinorStyle.Show) || (!gl.IsMinor && ya.GridMajorStyle.Show) {
				defaults := ya.GridMajorStyle
				if gl.IsMinor {
					defaults = ya.GridMinorStyle
				}
				gl.Render(r, canvasBox, ra, false, gl.Style.InheritFrom(defaults))
			}
		}
	}
}
307672
func (d *Docker) UnmarshalTOML(data interface{}) error {
	dataOK, ok := data.(map[string]interface{})
	if !ok {
		return errors.New("bad endpoint for docker input plugin")
	}
	d.Endpoint, _ = dataOK["endpoint"].(string)
	return nil
}
1161028
func YAMLMatcher(path string) bool {
	ext := filepath.Ext(path)
	return ext == ".yaml" || ext == ".yml"
}
627377
func (e Env) Marshal() (string, error) {
	x, err := xml.Marshal(e)
	if err != nil {
		return "", err
	}

	return fmt.Sprintf("%s%s", xml.Header, x), nil
}
558073
func (cfg *centOSCloudConfig) RenderYAML() ([]byte, error) {
	// Save the fields that we will modify
	var oldruncmds []string
	oldruncmds = copyStringSlice(cfg.RunCmds())

	// check for package proxy setting and add commands:
	var proxy string
	if proxy = cfg.PackageProxy(); proxy != "" {
		cfg.AddRunCmd(cfg.helper.addPackageProxyCmd(proxy))
		cfg.UnsetPackageProxy()
	}

	// check for package mirror settings and add commands:
	var mirror string
	if mirror = cfg.PackageMirror(); mirror != "" {
		cfg.AddRunCmd(addPackageMirrorCmd(cfg, mirror))
		cfg.UnsetPackageMirror()
	}

	// add appropriate commands for package sources configuration:
	srcs := cfg.PackageSources()
	for _, src := range srcs {
		cfg.AddScripts(addPackageSourceCmds(cfg, src)...)
	}
	cfg.UnsetAttr("package_sources")

	data, err := yaml.Marshal(cfg.attrs)
	if err != nil {
		return nil, err
	}

	// Restore the modified fields
	cfg.SetPackageProxy(proxy)
	cfg.SetPackageMirror(mirror)
	cfg.SetAttr("package_sources", srcs)
	if oldruncmds != nil {
		cfg.SetAttr("runcmd", oldruncmds)
	} else {
		cfg.UnsetAttr("runcmd")
	}

	return append([]byte("#cloud-config\n"), data...), nil
}
266724
func (auth Auth) MarshalYAML() (interface{}, error) {
	if auth.Parameters() == nil {
		return auth.Type(), nil
	}
	return map[string]Parameters(auth), nil
}
827108
func WriteYAML(w io.Writer, values interface{}) error {
	if reflect.TypeOf(values).Kind() != reflect.Slice {
		return trace.Wrap(writeYAML(w, values))
	}
	// first pass makes sure that all values are documents (objects or maps)
	slice := reflect.ValueOf(values)
	allDocs := func() bool {
		for i := 0; i < slice.Len(); i++ {
			if !isDoc(slice.Index(i)) {
				return false
			}
		}
		return true
	}
	if !allDocs() {
		return trace.Wrap(writeYAML(w, values))
	}
	// second pass can marshal documents
	for i := 0; i < slice.Len(); i++ {
		err := writeYAML(w, slice.Index(i).Interface())
		if err != nil {
			return trace.Wrap(err)
		}
		if i != slice.Len()-1 {
			if _, err := w.Write([]byte(yamlDocDelimiter + "\n")); err != nil {
				return trace.Wrap(err)
			}
		}
	}
	return nil
}