grype/internal/version/build.go
Christopher Angelo Phillips fe00b3c314
Enhance version cmd with SYFT_VERSION (#420)
* update command to take in SYFT_VERSION

Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com>

* add dynamic input to build command for ci

Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com>
2021-09-16 16:08:07 -04:00

39 lines
953 B
Go

package version
import (
"fmt"
"runtime"
)
const valueNotProvided = "[not provided]"
var version = valueNotProvided
var syftVersion = valueNotProvided
var gitCommit = valueNotProvided
var gitTreeState = valueNotProvided
var buildDate = valueNotProvided
var platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
type Version struct {
Version string `json:"version"`
SyftVersion string `json:"syftVersion"`
GitCommit string `json:"gitCommit"`
GitTreeState string `json:"gitTreeState"`
BuildDate string `json:"buildDate"`
GoVersion string `json:"goVersion"`
Compiler string `json:"compiler"`
Platform string `json:"platform"`
}
func FromBuild() Version {
return Version{
Version: version,
SyftVersion: syftVersion,
GitCommit: gitCommit,
GitTreeState: gitTreeState,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: platform,
}
}