Skip to content

Commit

Permalink
feat: introduce exit code failure option for db update check (#1463)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people authored Sep 14, 2023
1 parent b952d38 commit a87e198
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/grype/cli/commands/db_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"fmt"
"os"

"github.com/spf13/cobra"

Expand All @@ -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())

Expand Down Expand Up @@ -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
}

0 comments on commit a87e198

Please sign in to comment.