Skip to content

Commit

Permalink
chore: removes changes to and commands
Browse files Browse the repository at this point in the history
Signed-off-by: Adnan Gulegulzar <gulegulzaradnan@gmail.com>
  • Loading branch information
ADorigi committed Oct 22, 2024
1 parent f2dac42 commit 2ad25c4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
3 changes: 1 addition & 2 deletions cmd/grype/cli/commands/db_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/anchore/grype/cmd/grype/cli/options"
"github.com/anchore/grype/grype/db/legacy/distribution"
"github.com/anchore/grype/grype/differ"
"github.com/anchore/grype/internal"
"github.com/anchore/grype/internal/bus"
"github.com/anchore/grype/internal/log"
)
Expand All @@ -30,7 +29,7 @@ func (d *dbDiffOptions) AddFlags(flags clio.FlagSet) {

func DBDiff(app clio.Application) *cobra.Command {
opts := &dbDiffOptions{
Output: internal.TableOutputFormat,
Output: "table",
DBOptions: *dbOptionsDefault(app.ID()),
}

Expand Down
9 changes: 4 additions & 5 deletions cmd/grype/cli/commands/db_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/anchore/clio"
"github.com/anchore/grype/grype/db/legacy/distribution"
"github.com/anchore/grype/internal"
)

type dbListOptions struct {
Expand All @@ -25,7 +24,7 @@ func (d *dbListOptions) AddFlags(flags clio.FlagSet) {

func DBList(app clio.Application) *cobra.Command {
opts := &dbListOptions{
Output: internal.TextOutputFormat,
Output: "text",
DBOptions: *dbOptionsDefault(app.ID()),
}

Expand Down Expand Up @@ -59,7 +58,7 @@ func runDBList(opts *dbListOptions) error {
}

switch opts.Output {
case internal.TextOutputFormat:
case "text":
// summarize each listing entry for the current DB schema
for _, l := range available {
fmt.Printf("Built: %s\n", l.Built)
Expand All @@ -68,15 +67,15 @@ func runDBList(opts *dbListOptions) error {
}

fmt.Printf("%d databases available for schema %d\n", len(available), supportedSchema)
case internal.JSONOutputFormat:
case "json":
// show entries for the current schema
enc := json.NewEncoder(os.Stdout)
enc.SetEscapeHTML(false)
enc.SetIndent("", " ")
if err := enc.Encode(&available); err != nil {
return fmt.Errorf("failed to db listing information: %+v", err)
}
case internal.RawOutputFormat:
case "raw":
// show the entire listing file
enc := json.NewEncoder(os.Stdout)
enc.SetEscapeHTML(false)
Expand Down
2 changes: 0 additions & 2 deletions cmd/grype/cli/commands/db_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func DBProviders(app clio.Application) *cobra.Command {
}

func runDBProviders(opts *dbProvidersOptions, app clio.Application) error {

metadataFileLocation, err := getMetadataFileLocation(app)
if err != nil {
return nil
Expand Down Expand Up @@ -83,7 +82,6 @@ func runDBProviders(opts *dbProvidersOptions, app clio.Application) error {
}

func getMetadataFileLocation(app clio.Application) (*string, error) {

dbCurator, err := distribution.NewCurator(dbOptionsDefault(app.ID()).DB.ToCuratorConfig())
if err != nil {
return nil, err
Expand Down
12 changes: 6 additions & 6 deletions cmd/grype/cli/commands/db_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func TestGetDBProviders(t *testing.T) {
fileLocation: "./test-fixtures",
expectedProviders: dbProviders{
Providers: []dbProviderMetadata{
dbProviderMetadata{
{
Name: "provider1",
LastSuccessfulRun: "2024-10-16T01:33:16.844201Z",
},
dbProviderMetadata{
{
Name: "provider2",
LastSuccessfulRun: "2024-10-16T01:32:43.516596Z",
},
Expand Down Expand Up @@ -70,11 +70,11 @@ func TestDisplayDBProvidersTable(t *testing.T) {
name: "display providers table",
providers: dbProviders{
Providers: []dbProviderMetadata{
dbProviderMetadata{
{
Name: "provider1",
LastSuccessfulRun: "2024-10-16T01:33:16.844201Z",
},
dbProviderMetadata{
{
Name: "provider2",
LastSuccessfulRun: "2024-10-16T01:32:43.516596Z",
},
Expand Down Expand Up @@ -114,11 +114,11 @@ func TestDisplayDBProvidersJSON(t *testing.T) {
name: "display providers table",
providers: dbProviders{
Providers: []dbProviderMetadata{
dbProviderMetadata{
{
Name: "provider1",
LastSuccessfulRun: "2024-10-16T01:33:16.844201Z",
},
dbProviderMetadata{
{
Name: "provider2",
LastSuccessfulRun: "2024-10-16T01:32:43.516596Z",
},
Expand Down

0 comments on commit 2ad25c4

Please # to comment.