mirror of
https://github.com/anchore/syft.git
synced 2026-02-15 03:56:40 +01:00
Add SchemaVersion to version command output (#877)
* make JsonSchemaVersion available programmatically via syft version command Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
This commit is contained in:
parent
9d9669e62f
commit
003d28ad48
@ -31,6 +31,7 @@ func printVersion(_ *cobra.Command, _ []string) {
|
||||
case "text":
|
||||
fmt.Println("Application: ", internal.ApplicationName)
|
||||
fmt.Println("Version: ", versionInfo.Version)
|
||||
fmt.Println("JsonSchemaVersion: ", internal.JSONSchemaVersion)
|
||||
fmt.Println("BuildDate: ", versionInfo.BuildDate)
|
||||
fmt.Println("GitCommit: ", versionInfo.GitCommit)
|
||||
fmt.Println("GitDescription: ", versionInfo.GitDescription)
|
||||
|
||||
@ -7,6 +7,8 @@ import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
)
|
||||
|
||||
const valueNotProvided = "[not provided]"
|
||||
@ -21,6 +23,7 @@ var platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
// Version defines the application version details (generally from build information)
|
||||
type Version struct {
|
||||
Version string `json:"version"` // application semantic version
|
||||
JSONSchemaVersion string `json:"jsonSchemaVersion"` // application semantic JSON schema version
|
||||
GitCommit string `json:"gitCommit"` // git SHA at build-time
|
||||
GitDescription string `json:"gitDescription"` // output of 'git describe --dirty --always --tags'
|
||||
BuildDate string `json:"buildDate"` // date of the build
|
||||
@ -40,6 +43,7 @@ func (v Version) IsProductionBuild() bool {
|
||||
func FromBuild() Version {
|
||||
return Version{
|
||||
Version: version,
|
||||
JSONSchemaVersion: internal.JSONSchemaVersion,
|
||||
GitCommit: gitCommit,
|
||||
GitDescription: gitDescription,
|
||||
BuildDate: buildDate,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user