mirror of
https://github.com/anchore/syft.git
synced 2026-02-14 03:26:41 +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
@ -29,14 +29,15 @@ func printVersion(_ *cobra.Command, _ []string) {
|
|||||||
|
|
||||||
switch versionCmdOutputFormat {
|
switch versionCmdOutputFormat {
|
||||||
case "text":
|
case "text":
|
||||||
fmt.Println("Application: ", internal.ApplicationName)
|
fmt.Println("Application: ", internal.ApplicationName)
|
||||||
fmt.Println("Version: ", versionInfo.Version)
|
fmt.Println("Version: ", versionInfo.Version)
|
||||||
fmt.Println("BuildDate: ", versionInfo.BuildDate)
|
fmt.Println("JsonSchemaVersion: ", internal.JSONSchemaVersion)
|
||||||
fmt.Println("GitCommit: ", versionInfo.GitCommit)
|
fmt.Println("BuildDate: ", versionInfo.BuildDate)
|
||||||
fmt.Println("GitDescription: ", versionInfo.GitDescription)
|
fmt.Println("GitCommit: ", versionInfo.GitCommit)
|
||||||
fmt.Println("Platform: ", versionInfo.Platform)
|
fmt.Println("GitDescription: ", versionInfo.GitDescription)
|
||||||
fmt.Println("GoVersion: ", versionInfo.GoVersion)
|
fmt.Println("Platform: ", versionInfo.Platform)
|
||||||
fmt.Println("Compiler: ", versionInfo.Compiler)
|
fmt.Println("GoVersion: ", versionInfo.GoVersion)
|
||||||
|
fmt.Println("Compiler: ", versionInfo.Compiler)
|
||||||
|
|
||||||
case "json":
|
case "json":
|
||||||
enc := json.NewEncoder(os.Stdout)
|
enc := json.NewEncoder(os.Stdout)
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
const valueNotProvided = "[not provided]"
|
const valueNotProvided = "[not provided]"
|
||||||
@ -20,13 +22,14 @@ var platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
|
|||||||
|
|
||||||
// Version defines the application version details (generally from build information)
|
// Version defines the application version details (generally from build information)
|
||||||
type Version struct {
|
type Version struct {
|
||||||
Version string `json:"version"` // application semantic version
|
Version string `json:"version"` // application semantic version
|
||||||
GitCommit string `json:"gitCommit"` // git SHA at build-time
|
JSONSchemaVersion string `json:"jsonSchemaVersion"` // application semantic JSON schema version
|
||||||
GitDescription string `json:"gitDescription"` // output of 'git describe --dirty --always --tags'
|
GitCommit string `json:"gitCommit"` // git SHA at build-time
|
||||||
BuildDate string `json:"buildDate"` // date of the build
|
GitDescription string `json:"gitDescription"` // output of 'git describe --dirty --always --tags'
|
||||||
GoVersion string `json:"goVersion"` // go runtime version at build-time
|
BuildDate string `json:"buildDate"` // date of the build
|
||||||
Compiler string `json:"compiler"` // compiler used at build-time
|
GoVersion string `json:"goVersion"` // go runtime version at build-time
|
||||||
Platform string `json:"platform"` // GOOS and GOARCH at build-time
|
Compiler string `json:"compiler"` // compiler used at build-time
|
||||||
|
Platform string `json:"platform"` // GOOS and GOARCH at build-time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v Version) IsProductionBuild() bool {
|
func (v Version) IsProductionBuild() bool {
|
||||||
@ -39,12 +42,13 @@ func (v Version) IsProductionBuild() bool {
|
|||||||
// FromBuild provides all version details
|
// FromBuild provides all version details
|
||||||
func FromBuild() Version {
|
func FromBuild() Version {
|
||||||
return Version{
|
return Version{
|
||||||
Version: version,
|
Version: version,
|
||||||
GitCommit: gitCommit,
|
JSONSchemaVersion: internal.JSONSchemaVersion,
|
||||||
GitDescription: gitDescription,
|
GitCommit: gitCommit,
|
||||||
BuildDate: buildDate,
|
GitDescription: gitDescription,
|
||||||
GoVersion: runtime.Version(),
|
BuildDate: buildDate,
|
||||||
Compiler: runtime.Compiler,
|
GoVersion: runtime.Version(),
|
||||||
Platform: platform,
|
Compiler: runtime.Compiler,
|
||||||
|
Platform: platform,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user