mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
add db schema output option
This commit is contained in:
parent
c61483cb23
commit
6ead045457
2 changed files with 23 additions and 8 deletions
|
@ -9,6 +9,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var showSupportedDbSchema bool
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "display database status",
|
||||
|
@ -18,6 +20,9 @@ var statusCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func init() {
|
||||
// Note: this option cannot change as it supports the nightly DB generation job
|
||||
statusCmd.Flags().BoolVar(&showSupportedDbSchema, "schema", false, "show supported DB schema")
|
||||
|
||||
dbCmd.AddCommand(statusCmd)
|
||||
}
|
||||
|
||||
|
@ -29,6 +34,13 @@ func runDbStatusCmd(_ *cobra.Command, _ []string) int {
|
|||
}
|
||||
|
||||
status := dbCurator.Status()
|
||||
|
||||
if showSupportedDbSchema {
|
||||
// Note: the output for this option cannot change as it supports the nightly DB generation job
|
||||
fmt.Println(status.RequiredSchemeVersion)
|
||||
return 0
|
||||
}
|
||||
|
||||
fmt.Println("Location: ", status.Location)
|
||||
fmt.Println("Built: ", status.Age.String())
|
||||
fmt.Println("Current DB Version: ", status.CurrentSchemaVersion)
|
||||
|
|
|
@ -3,6 +3,8 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anchore/grype-db/pkg/db"
|
||||
|
||||
"github.com/anchore/grype/internal"
|
||||
"github.com/anchore/grype/internal/version"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -25,14 +27,15 @@ func init() {
|
|||
func printVersion(_ *cobra.Command, _ []string) {
|
||||
versionInfo := version.FromBuild()
|
||||
if showVerboseVersionInfo {
|
||||
fmt.Println("Application: ", internal.ApplicationName)
|
||||
fmt.Println("Version: ", versionInfo.Version)
|
||||
fmt.Println("BuildDate: ", versionInfo.BuildDate)
|
||||
fmt.Println("GitCommit: ", versionInfo.GitCommit)
|
||||
fmt.Println("GitTreeState: ", versionInfo.GitTreeState)
|
||||
fmt.Println("Platform: ", versionInfo.Platform)
|
||||
fmt.Println("GoVersion: ", versionInfo.GoVersion)
|
||||
fmt.Println("Compiler: ", versionInfo.Compiler)
|
||||
fmt.Println("Application: ", internal.ApplicationName)
|
||||
fmt.Println("Version: ", versionInfo.Version)
|
||||
fmt.Println("BuildDate: ", versionInfo.BuildDate)
|
||||
fmt.Println("GitCommit: ", versionInfo.GitCommit)
|
||||
fmt.Println("GitTreeState: ", versionInfo.GitTreeState)
|
||||
fmt.Println("Platform: ", versionInfo.Platform)
|
||||
fmt.Println("GoVersion: ", versionInfo.GoVersion)
|
||||
fmt.Println("Compiler: ", versionInfo.Compiler)
|
||||
fmt.Println("Supported DB Schema: ", db.SchemaVersion)
|
||||
} else {
|
||||
fmt.Printf("%s %s\n", internal.ApplicationName, versionInfo.Version)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue