mirror of
https://github.com/anchore/grype
synced 2024-11-10 14:44:12 +00:00
fe00b3c314
* 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>
39 lines
953 B
Go
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,
|
|
}
|
|
}
|