Skip to content

Commit e0ca5ef

Browse files
authored
feat(commands): remove deprecated options (#1270)
1 parent 1ebb329 commit e0ca5ef

File tree

3 files changed

+1
-57
lines changed

3 files changed

+1
-57
lines changed

pkg/commands/app.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -312,25 +312,6 @@ var (
312312
stringSliceFlag(skipFiles),
313313
stringSliceFlag(skipDirs),
314314
}
315-
316-
// deprecated options
317-
deprecatedFlags = []cli.Flag{
318-
&cli.StringFlag{
319-
Name: "only-update",
320-
Usage: "deprecated",
321-
EnvVars: []string{"TRIVY_ONLY_UPDATE"},
322-
},
323-
&cli.BoolFlag{
324-
Name: "refresh",
325-
Usage: "deprecated",
326-
EnvVars: []string{"TRIVY_REFRESH"},
327-
},
328-
&cli.BoolFlag{
329-
Name: "auto-refresh",
330-
Usage: "deprecated",
331-
EnvVars: []string{"TRIVY_AUTO_REFRESH"},
332-
},
333-
}
334315
)
335316

336317
// NewApp is the factory method to return Trivy CLI
@@ -346,8 +327,7 @@ func NewApp(version string) *cli.App {
346327
app.Usage = "A simple and comprehensive vulnerability scanner for containers"
347328
app.EnableBashCompletion = true
348329

349-
flags := append(globalFlags, setHidden(deprecatedFlags, true)...)
350-
flags = append(flags, setHidden(imageFlags, true)...)
330+
flags := append(globalFlags, setHidden(imageFlags, true)...)
351331

352332
app.Flags = flags
353333
app.Commands = []*cli.Command{

pkg/commands/artifact/option.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ type Option struct {
1616
option.ReportOption
1717
option.CacheOption
1818
option.ConfigOption
19-
20-
// deprecated
21-
onlyUpdate string
22-
// deprecated
23-
refresh bool
24-
// deprecated
25-
autoRefresh bool
2619
}
2720

2821
// NewOption is the factory method to return options
@@ -40,19 +33,11 @@ func NewOption(c *cli.Context) (Option, error) {
4033
ReportOption: option.NewReportOption(c),
4134
CacheOption: option.NewCacheOption(c),
4235
ConfigOption: option.NewConfigOption(c),
43-
44-
onlyUpdate: c.String("only-update"),
45-
refresh: c.Bool("refresh"),
46-
autoRefresh: c.Bool("auto-refresh"),
4736
}, nil
4837
}
4938

5039
// Init initializes the artifact options
5140
func (c *Option) Init() error {
52-
if c.onlyUpdate != "" || c.refresh || c.autoRefresh {
53-
c.Logger.Warn("--only-update, --refresh and --auto-refresh are unnecessary and ignored now. These commands will be removed in the next version.")
54-
}
55-
5641
if err := c.initPreScanOptions(); err != nil {
5742
return err
5843
}

pkg/commands/artifact/option_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,6 @@ func TestOption_Init(t *testing.T) {
9393
},
9494
},
9595
},
96-
{
97-
name: "deprecated options",
98-
args: []string{"--only-update", "alpine", "--severity", "LOW", "debian:buster"},
99-
logs: []string{
100-
"--only-update, --refresh and --auto-refresh are unnecessary and ignored now. These commands will be removed in the next version.",
101-
},
102-
want: Option{
103-
ReportOption: option.ReportOption{
104-
Severities: []dbTypes.Severity{dbTypes.SeverityLow},
105-
Output: os.Stdout,
106-
VulnType: []string{types.VulnTypeOS, types.VulnTypeLibrary},
107-
SecurityChecks: []string{types.SecurityCheckVulnerability},
108-
},
109-
ArtifactOption: option.ArtifactOption{
110-
Target: "debian:buster",
111-
},
112-
onlyUpdate: "alpine",
113-
},
114-
},
11596
{
11697
name: "invalid option combination: --template enabled without --format",
11798
args: []string{"--template", "@contrib/gitlab.tpl", "gitlab/gitlab-ce:12.7.2-ce.0"},
@@ -196,11 +177,9 @@ func TestOption_Init(t *testing.T) {
196177
set.Bool("reset", false, "")
197178
set.Bool("skip-db-update", false, "")
198179
set.Bool("download-db-only", false, "")
199-
set.Bool("auto-refresh", false, "")
200180
set.String("severity", "CRITICAL", "")
201181
set.String("vuln-type", "os,library", "")
202182
set.String("security-checks", "vuln", "")
203-
set.String("only-update", "", "")
204183
set.String("template", "", "")
205184
set.String("format", "", "")
206185

0 commit comments

Comments
 (0)