Skip to content

Commit

Permalink
keep config shape clean
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Dec 23, 2024
1 parent 0012ff8 commit c410aa6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion cmd/grype/cli/commands/db_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ Global Flags:
DBSearchVulnerabilities(app),
)

return app.SetupCommand(cmd, opts)
// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbSearchMatchOptions `json:"-" yaml:"-" mapstructure:"-"`
}

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

func runDBSearchMatches(opts dbSearchMatchOptions) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_search_vuln.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func DBSearchVulnerabilities(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "vuln ID...",
Aliases: []string{"vulnerability", "vulnerabilities", "vulns"},
Short: "Search for vulnerabilities within the DB (supports DB schema v6+ only)",
Expand All @@ -56,7 +56,14 @@ func DBSearchVulnerabilities(app clio.Application) *cobra.Command {
}
return runDBSearchVulnerabilities(*opts)
},
}, opts)
}

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

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

func runDBSearchVulnerabilities(opts dbSearchVulnerabilityOptions) error {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/db_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestDBProviders(t *testing.T) {
name: "db providers command help",
args: []string{"db", "providers", "-h"},
assertions: []traitAssertion{
assertInOutput("List vulnerability database providers"),
assertInOutput("List vulnerability providers that are in the database"),
assertNoStderr,
},
},
Expand Down

0 comments on commit c410aa6

Please sign in to comment.