diff --git a/pkg/commands/app.go b/pkg/commands/app.go index 90c737a040bb..97ff44dc392a 100644 --- a/pkg/commands/app.go +++ b/pkg/commands/app.go @@ -93,7 +93,6 @@ func NewApp() *cobra.Command { NewKubernetesCommand(globalFlags), NewSBOMCommand(globalFlags), NewVersionCommand(globalFlags), - NewAWSCommand(), NewVMCommand(globalFlags), ) @@ -105,6 +104,15 @@ func NewApp() *cobra.Command { rootCmd.AddCommand(plugins...) } + // TODO(simar7): Only for backwards support guidance, delete the subcommand after a while. + if cmd, _, _ := rootCmd.Find([]string{"aws"}); cmd == cmd.Root() { // "trivy aws" not installed + rootCmd.AddCommand(&cobra.Command{ + Hidden: true, + Long: "Trivy AWS is now available as an optional plugin. See github.com/aquasecurity/trivy-aws for details.", + Use: "aws", + }) + } + return rootCmd } @@ -1014,14 +1022,6 @@ func NewKubernetesCommand(globalFlags *flag.GlobalFlagGroup) *cobra.Command { return cmd } -func NewAWSCommand() *cobra.Command { - cmd := &cobra.Command{ - Deprecated: "Trivy AWS is now available as an optional plugin. See github.com/aquasecurity/trivy-aws for details", - Use: "aws [flags]", - } - return cmd -} - func NewVMCommand(globalFlags *flag.GlobalFlagGroup) *cobra.Command { vmFlags := &flag.Flags{ GlobalFlagGroup: globalFlags, diff --git a/pkg/flag/cloud_flags.go b/pkg/flag/cloud_flags.go deleted file mode 100644 index fd96c206d496..000000000000 --- a/pkg/flag/cloud_flags.go +++ /dev/null @@ -1,55 +0,0 @@ -package flag - -import "time" - -var ( - cloudUpdateCacheFlag = Flag[bool]{ - Name: "update-cache", - ConfigName: "cloud.update-cache", - Usage: "Update the cache for the applicable cloud provider instead of using cached results.", - } - cloudMaxCacheAgeFlag = Flag[time.Duration]{ - Name: "max-cache-age", - ConfigName: "cloud.max-cache-age", - Default: time.Hour * 24, - Usage: "The maximum age of the cloud cache. Cached data will be required from the cloud provider if it is older than this.", - } -) - -type CloudFlagGroup struct { - UpdateCache *Flag[bool] - MaxCacheAge *Flag[time.Duration] -} - -type CloudOptions struct { - MaxCacheAge time.Duration - UpdateCache bool -} - -func NewCloudFlagGroup() *CloudFlagGroup { - return &CloudFlagGroup{ - UpdateCache: cloudUpdateCacheFlag.Clone(), - MaxCacheAge: cloudMaxCacheAgeFlag.Clone(), - } -} - -func (f *CloudFlagGroup) Name() string { - return "Cloud" -} - -func (f *CloudFlagGroup) Flags() []Flagger { - return []Flagger{ - f.UpdateCache, - f.MaxCacheAge, - } -} - -func (f *CloudFlagGroup) ToOptions() (CloudOptions, error) { - if err := parseFlags(f); err != nil { - return CloudOptions{}, err - } - return CloudOptions{ - UpdateCache: f.UpdateCache.Value(), - MaxCacheAge: f.MaxCacheAge.Value(), - }, nil -} diff --git a/pkg/flag/options.go b/pkg/flag/options.go index 3777bed507fb..db042ff802a1 100644 --- a/pkg/flag/options.go +++ b/pkg/flag/options.go @@ -301,7 +301,6 @@ type Flags struct { GlobalFlagGroup *GlobalFlagGroup AWSFlagGroup *AWSFlagGroup CacheFlagGroup *CacheFlagGroup - CloudFlagGroup *CloudFlagGroup DBFlagGroup *DBFlagGroup ImageFlagGroup *ImageFlagGroup K8sFlagGroup *K8sFlagGroup @@ -324,7 +323,6 @@ type Options struct { GlobalOptions AWSOptions CacheOptions - CloudOptions DBOptions ImageOptions K8sOptions @@ -527,9 +525,6 @@ func (f *Flags) groups() []FlagGroup { if f.RegoFlagGroup != nil { groups = append(groups, f.RegoFlagGroup) } - if f.CloudFlagGroup != nil { - groups = append(groups, f.CloudFlagGroup) - } if f.AWSFlagGroup != nil { groups = append(groups, f.AWSFlagGroup) } @@ -619,13 +614,6 @@ func (f *Flags) ToOptions(args []string) (Options, error) { } } - if f.CloudFlagGroup != nil { - opts.CloudOptions, err = f.CloudFlagGroup.ToOptions() - if err != nil { - return Options{}, xerrors.Errorf("cloud flag error: %w", err) - } - } - if f.CacheFlagGroup != nil { opts.CacheOptions, err = f.CacheFlagGroup.ToOptions() if err != nil {