diff --git a/pkg/buildinfo/buildinfo.go b/pkg/buildinfo/buildinfo.go index bd114cb5d5..f460f64aca 100644 --- a/pkg/buildinfo/buildinfo.go +++ b/pkg/buildinfo/buildinfo.go @@ -13,18 +13,22 @@ var ( date = unknown ) +// Version returns version from git describe. func Version() string { return version } +// Commit returns commit hash. func Commit() string { return commit } +// Date returns date of build in RFC3339 format. func Date() string { return date } +// Get returns build info summary. func Get() *Info { return &Info{ Version: Version(), @@ -33,13 +37,16 @@ func Get() *Info { } } +// Info is build info summary. type Info struct { Version string `json:"version"` Commit string `json:"commit"` Date string `json:"date"` } -func (info *Info) WriteTo(w io.Writer) (n int, err error) { +// WriteTo writes build info summary to io.Writer. +func (info *Info) WriteTo(w io.Writer) (int64, error) { msg := fmt.Sprintf("Version %q built on %q agaist commit %q\n", info.Version, info.Date, info.Commit) - return w.Write([]byte(msg)) + n, err := w.Write([]byte(msg)) + return int64(n), err }