From e0ca5eff38e87941c364187c41d8c71c0be3f675 Mon Sep 17 00:00:00 2001 From: Teppei Fukuda Date: Mon, 4 Oct 2021 21:49:04 +0900 Subject: [PATCH] feat(commands): remove deprecated options (#1270) --- pkg/commands/app.go | 22 +--------------------- pkg/commands/artifact/option.go | 15 --------------- pkg/commands/artifact/option_test.go | 21 --------------------- 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/pkg/commands/app.go b/pkg/commands/app.go index 12cf26ddd816..ceecffd38da9 100644 --- a/pkg/commands/app.go +++ b/pkg/commands/app.go @@ -312,25 +312,6 @@ var ( stringSliceFlag(skipFiles), stringSliceFlag(skipDirs), } - - // deprecated options - deprecatedFlags = []cli.Flag{ - &cli.StringFlag{ - Name: "only-update", - Usage: "deprecated", - EnvVars: []string{"TRIVY_ONLY_UPDATE"}, - }, - &cli.BoolFlag{ - Name: "refresh", - Usage: "deprecated", - EnvVars: []string{"TRIVY_REFRESH"}, - }, - &cli.BoolFlag{ - Name: "auto-refresh", - Usage: "deprecated", - EnvVars: []string{"TRIVY_AUTO_REFRESH"}, - }, - } ) // NewApp is the factory method to return Trivy CLI @@ -346,8 +327,7 @@ func NewApp(version string) *cli.App { app.Usage = "A simple and comprehensive vulnerability scanner for containers" app.EnableBashCompletion = true - flags := append(globalFlags, setHidden(deprecatedFlags, true)...) - flags = append(flags, setHidden(imageFlags, true)...) + flags := append(globalFlags, setHidden(imageFlags, true)...) app.Flags = flags app.Commands = []*cli.Command{ diff --git a/pkg/commands/artifact/option.go b/pkg/commands/artifact/option.go index ca130e341430..894f39cb5a94 100644 --- a/pkg/commands/artifact/option.go +++ b/pkg/commands/artifact/option.go @@ -16,13 +16,6 @@ type Option struct { option.ReportOption option.CacheOption option.ConfigOption - - // deprecated - onlyUpdate string - // deprecated - refresh bool - // deprecated - autoRefresh bool } // NewOption is the factory method to return options @@ -40,19 +33,11 @@ func NewOption(c *cli.Context) (Option, error) { ReportOption: option.NewReportOption(c), CacheOption: option.NewCacheOption(c), ConfigOption: option.NewConfigOption(c), - - onlyUpdate: c.String("only-update"), - refresh: c.Bool("refresh"), - autoRefresh: c.Bool("auto-refresh"), }, nil } // Init initializes the artifact options func (c *Option) Init() error { - if c.onlyUpdate != "" || c.refresh || c.autoRefresh { - c.Logger.Warn("--only-update, --refresh and --auto-refresh are unnecessary and ignored now. These commands will be removed in the next version.") - } - if err := c.initPreScanOptions(); err != nil { return err } diff --git a/pkg/commands/artifact/option_test.go b/pkg/commands/artifact/option_test.go index f65a6194a68b..e4a8344e3ccc 100644 --- a/pkg/commands/artifact/option_test.go +++ b/pkg/commands/artifact/option_test.go @@ -93,25 +93,6 @@ func TestOption_Init(t *testing.T) { }, }, }, - { - name: "deprecated options", - args: []string{"--only-update", "alpine", "--severity", "LOW", "debian:buster"}, - logs: []string{ - "--only-update, --refresh and --auto-refresh are unnecessary and ignored now. These commands will be removed in the next version.", - }, - want: Option{ - ReportOption: option.ReportOption{ - Severities: []dbTypes.Severity{dbTypes.SeverityLow}, - Output: os.Stdout, - VulnType: []string{types.VulnTypeOS, types.VulnTypeLibrary}, - SecurityChecks: []string{types.SecurityCheckVulnerability}, - }, - ArtifactOption: option.ArtifactOption{ - Target: "debian:buster", - }, - onlyUpdate: "alpine", - }, - }, { name: "invalid option combination: --template enabled without --format", args: []string{"--template", "@contrib/gitlab.tpl", "gitlab/gitlab-ce:12.7.2-ce.0"}, @@ -196,11 +177,9 @@ func TestOption_Init(t *testing.T) { set.Bool("reset", false, "") set.Bool("skip-db-update", false, "") set.Bool("download-db-only", false, "") - set.Bool("auto-refresh", false, "") set.String("severity", "CRITICAL", "") set.String("vuln-type", "os,library", "") set.String("security-checks", "vuln", "") - set.String("only-update", "", "") set.String("template", "", "") set.String("format", "", "")