mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 23:26:39 -08:00
* refactor: rename Value to Default * refactor: support allowed values for CLI flags * docs: auto-generate * test: fix * test: add tests for flags
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package flag
|
|
|
|
import "time"
|
|
|
|
var (
|
|
cloudUpdateCacheFlag = Flag{
|
|
Name: "update-cache",
|
|
ConfigName: "cloud.update-cache",
|
|
Default: false,
|
|
Usage: "Update the cache for the applicable cloud provider instead of using cached results.",
|
|
}
|
|
cloudMaxCacheAgeFlag = Flag{
|
|
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 requeried from the cloud provider if it is older than this.",
|
|
}
|
|
)
|
|
|
|
type CloudFlagGroup struct {
|
|
UpdateCache *Flag
|
|
MaxCacheAge *Flag
|
|
}
|
|
|
|
type CloudOptions struct {
|
|
MaxCacheAge time.Duration
|
|
UpdateCache bool
|
|
}
|
|
|
|
func NewCloudFlagGroup() *CloudFlagGroup {
|
|
return &CloudFlagGroup{
|
|
UpdateCache: &cloudUpdateCacheFlag,
|
|
MaxCacheAge: &cloudMaxCacheAgeFlag,
|
|
}
|
|
}
|
|
|
|
func (f *CloudFlagGroup) Name() string {
|
|
return "Cloud"
|
|
}
|
|
|
|
func (f *CloudFlagGroup) Flags() []*Flag {
|
|
return []*Flag{f.UpdateCache, f.MaxCacheAge}
|
|
}
|
|
|
|
func (f *CloudFlagGroup) ToOptions() CloudOptions {
|
|
return CloudOptions{
|
|
UpdateCache: getBool(f.UpdateCache),
|
|
MaxCacheAge: getDuration(f.MaxCacheAge),
|
|
}
|
|
}
|