feat: introduce exit code failure option for db update check (#1463)

Signed-off-by: Felix Becker <git@felixbecker.name>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
Co-authored-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
devfbe 2023-09-14 18:12:38 +02:00 committed by GitHub
parent b952d3808c
commit a87e198e58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package commands
import (
"fmt"
"os"
"github.com/spf13/cobra"
@ -11,6 +12,10 @@ import (
"github.com/anchore/grype/internal/bus"
)
const (
exitCodeOnDBUpgradeAvailable = 100
)
func DBCheck(app clio.Application) *cobra.Command {
opts := dbOptionsDefault(app.ID())
@ -51,5 +56,7 @@ func runDBCheck(opts options.Database) error {
fmt.Printf("Updated DB URL: %s\n", updateDBEntry.URL.String())
fmt.Println("You can run 'grype db update' to update to the latest db")
os.Exit(exitCodeOnDBUpgradeAvailable) //nolint:gocritic
return nil
}