Skip to content

Commit

Permalink
expose DB options
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Jan 8, 2025
1 parent ba91442 commit 2f03aff
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions cmd/grype/cli/commands/db_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func DBCheck(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbCheckOptions `json:"-" yaml:"-" mapstructure:"-"`
Hidden *dbCheckOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
return app.SetupCommand(cmd, &configWrapper{Hidden: opts, DBOptions: &opts.DBOptions})
}

func runDBCheck(opts dbCheckOptions) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func DBDelete(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *DBOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
Expand Down
5 changes: 3 additions & 2 deletions cmd/grype/cli/commands/db_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ func DBDiff(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbDiffOptions `json:"-" yaml:"-" mapstructure:"-"`
Hidden *dbDiffOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
return app.SetupCommand(cmd, &configWrapper{Hidden: opts, DBOptions: &opts.DBOptions})
}

func runDBDiff(opts *dbDiffOptions, base string, target string) (errs error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func DBImport(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *DBOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
Expand Down
5 changes: 3 additions & 2 deletions cmd/grype/cli/commands/db_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ func DBList(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbListOptions `json:"-" yaml:"-" mapstructure:"-"`
Hidden *dbListOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
return app.SetupCommand(cmd, &configWrapper{Hidden: opts, DBOptions: &opts.DBOptions})
}

func runDBList(opts dbListOptions) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/grype/cli/commands/db_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ func DBProviders(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbProvidersOptions `json:"-" yaml:"-" mapstructure:"-"`
Hidden *dbProvidersOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
return app.SetupCommand(cmd, &configWrapper{Hidden: opts, DBOptions: &opts.DBOptions})
}

func runDBProviders(opts *dbProvidersOptions, app clio.Application) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/grype/cli/commands/db_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ func DBSearch(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbQueryOptions `json:"-" yaml:"-" mapstructure:"-"`
Hidden *dbQueryOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
return app.SetupCommand(cmd, &configWrapper{Hidden: opts, DBOptions: &opts.DBOptions})
}

func runDBSearch(opts dbQueryOptions, vulnerabilityID string) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/grype/cli/commands/db_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ func DBStatus(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbStatusOptions `json:"-" yaml:"-" mapstructure:"-"`
Hidden *dbStatusOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
return app.SetupCommand(cmd, &configWrapper{Hidden: opts, DBOptions: &opts.DBOptions})
}

func runDBStatus(opts dbStatusOptions) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func DBUpdate(app clio.Application) *cobra.Command {

// prevent from being shown in the grype config
type configWrapper struct {
Opts *DBOptions `json:"-" yaml:"-" mapstructure:"-"`
*DBOptions `yaml:",inline" mapstructure:",squash"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
Expand Down

0 comments on commit 2f03aff

Please sign in to comment.