mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
move update force check to PreRunE
Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
This commit is contained in:
parent
5958361ae6
commit
786053e7cb
2 changed files with 14 additions and 8 deletions
|
@ -19,10 +19,15 @@ func DBCheck(app clio.Application) *cobra.Command {
|
|||
opts := dbOptionsDefault(app.ID())
|
||||
|
||||
return app.SetupCommand(&cobra.Command{
|
||||
Use: "check",
|
||||
Short: "check to see if there is a database update available",
|
||||
PreRunE: disableUI(app),
|
||||
Args: cobra.ExactArgs(0),
|
||||
Use: "check",
|
||||
Short: "check to see if there is a database update available",
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
// `grype db check` should _always_ check for updates, regardless of config
|
||||
opts.DB.MinAgeToCheckForUpdate = 0
|
||||
|
||||
return disableUI(app)(cmd, args)
|
||||
},
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
return runDBCheck(opts.DB)
|
||||
},
|
||||
|
@ -30,8 +35,6 @@ func DBCheck(app clio.Application) *cobra.Command {
|
|||
}
|
||||
|
||||
func runDBCheck(opts options.Database) error {
|
||||
// `grype db check` should _always_ check for updates, regardless of config
|
||||
opts.MinAgeToCheckForUpdate = 0
|
||||
dbCurator, err := db.NewCurator(opts.ToCuratorConfig())
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -19,6 +19,11 @@ func DBUpdate(app clio.Application) *cobra.Command {
|
|||
Use: "update",
|
||||
Short: "download the latest vulnerability database",
|
||||
Args: cobra.ExactArgs(0),
|
||||
PreRunE: func(_ *cobra.Command, _ []string) error {
|
||||
// `grype db update` should _always_ check for updates, regardless of config
|
||||
opts.DB.MinAgeToCheckForUpdate = 0
|
||||
return nil
|
||||
},
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
return runDBUpdate(opts.DB)
|
||||
},
|
||||
|
@ -26,8 +31,6 @@ func DBUpdate(app clio.Application) *cobra.Command {
|
|||
}
|
||||
|
||||
func runDBUpdate(opts options.Database) error {
|
||||
// `grype db update` should _always_ check for updates, regardless of config
|
||||
opts.MinAgeToCheckForUpdate = 0
|
||||
dbCurator, err := db.NewCurator(opts.ToCuratorConfig())
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue