prow/cmd/deck/badge.go
func makeShield(subject, status, color string) []byte {
	// TODO(rmmh): Use better font-size metrics for prettier badges-- estimating
	// character widths as 6px isn't very accurate.
	// See also: https://github.com/badges/shields/blob/master/measure-text.js
	p := struct {
		Width, RightStart, RightWidth int
		XposLeft, XposRight           float64
		Subject, Status               string
		Color                         string
	}{
		Subject:    subject,
		Status:     status,
		RightStart: 13 + 6*len(subject),
		RightWidth: 13 + 6*len(status),
	}
	p.Width = p.RightStart + p.RightWidth
	p.XposLeft = float64(p.RightStart) * 0.5
	p.XposRight = float64(p.RightStart) + float64(p.RightWidth-2)*0.5
	switch color {
	case "brightgreen":
		p.Color = "#4c1"
	case "red":
		p.Color = "#e05d44"
	default:
		p.Color = color
	}
	var buf bytes.Buffer
	svgTemplate.Execute(&buf, p)
	return buf.Bytes()
}
func makeShield(subject, status, color string) []byte {
	// TODO(rmmh): Use better font-size metrics for prettier badges-- estimating
	// character widths as 6px isn't very accurate.
	// See also: https://github.com/badges/shields/blob/master/measure-text.js
	p := struct {
		Width, RightStart, RightWidth int
		XposLeft, XposRight           float64
		Subject, Status               string
		Color                         string
	}{
		Subject:    subject,
		Status:     status,
		RightStart: 13 + 6*len(subject),
		RightWidth: 13 + 6*len(status),
	}
	p.Width = p.RightStart + p.RightWidth
	p.XposLeft = float64(p.RightStart) * 0.5
	p.XposRight = float64(p.RightStart) + float64(p.RightWidth-2)*0.5
	switch color {
	case "brightgreen":
		p.Color = "#4c1"
	case "red":
		p.Color = "#e05d44"
	default:
		p.Color = color
	}
	var buf bytes.Buffer
	svgTemplate.Execute(&buf, p)
	return buf.Bytes()
}
func makeShield ( subject , status , color string ) [ ] byte { // TODO(rmmh): Use better font-size metrics for prettier badges-- estimating // character widths as 6px isn't very accurate. // See also: https://github.com/badges/shields/blob/master/measure-text.js p := struct { Width , RightStart , RightWidth int XposLeft , XposRight float64 Subject , Status string Color string } { Subject : subject , Status : status , RightStart : 13 + 6 * len ( subject ) , RightWidth : 13 + 6 * len ( status ) , } p . Width = p . RightStart + p . RightWidth p . XposLeft = float64 ( p . RightStart ) * 0.5 p . XposRight = float64 ( p . RightStart ) + float64 ( p . RightWidth - 2 ) * 0.5 switch color { case " " : p . Color = " " case " " : p . Color = " " default : p . Color = color } var buf bytes . Buffer svgTemplate . Execute ( & buf , p ) return buf . Bytes ( ) }
// Make a small SVG badge that looks like `[subject | status]`, with the status
// text in the given color. Provides a local version of the shields.io service.
Make a small SVG badge that looks like [ subject | status ] with the status text in the given color . Provides a local version of the shields . io service .