mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Start api directory, which will become a module.
This commit is contained in:
54
api/provenance/provenance.go
Normal file
54
api/provenance/provenance.go
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package provenance
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "unknown"
|
||||
// sha1 from git, output of $(git rev-parse HEAD)
|
||||
gitCommit = "$Format:%H$"
|
||||
// build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
buildDate = "1970-01-01T00:00:00Z"
|
||||
goos = runtime.GOOS
|
||||
goarch = runtime.GOARCH
|
||||
)
|
||||
|
||||
// Provenance holds information about the build of an executable.
|
||||
type Provenance struct {
|
||||
// Version of the kustomize binary.
|
||||
Version string `json:"version"`
|
||||
// GitCommit is a git commit
|
||||
GitCommit string `json:"gitCommit"`
|
||||
// BuildDate is date of the build.
|
||||
BuildDate string `json:"buildDate"`
|
||||
// GoOs holds OS name.
|
||||
GoOs string `json:"goOs"`
|
||||
// GoArch holds architecture name.
|
||||
GoArch string `json:"goArch"`
|
||||
}
|
||||
|
||||
// GetProvenance returns an instance of Provenance.
|
||||
func GetProvenance() Provenance {
|
||||
return Provenance{
|
||||
version,
|
||||
gitCommit,
|
||||
buildDate,
|
||||
goos,
|
||||
goarch,
|
||||
}
|
||||
}
|
||||
|
||||
// Print prints provenance info.
|
||||
func (v Provenance) Print(w io.Writer, short bool) {
|
||||
if short {
|
||||
fmt.Fprintf(w, "%s\n", v.Version)
|
||||
} else {
|
||||
fmt.Fprintf(w, "Version: %+v\n", v)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user