Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ValidSortByOpts = []string{"size", "lastModificationDate"} // CleanCmd represents the clean command CleanCmd = &cobra.Command{ Use: "clean", Short: "finds and clears desired files by a pre-configured rule set", SilenceUsage: true, SilenceErrors: true, Example: `# clean the desired files on target bucket s3-manager clean --min-size-mb=1 --max-size-mb=1000 --keep-last-n-files=2 --sort-by=lastModificationDate `, RunE: func(cmd *cobra.Command, args []string) error { svc = cmd.Context().Value(rootopts.S3SvcKey{}).(s3iface.S3API) rootOpts := cmd.Context().Value(rootopts.OptsKey{}).(*rootopts.RootOptions) cleanOpts.RootOptions = rootOpts logger = logging.GetLogger(rootOpts) if cleanOpts.MinFileSizeInMb > cleanOpts.MaxFileSizeInMb && (cleanOpts.MinFileSizeInMb != 0 && cleanOpts.MaxFileSizeInMb != 0) { err := fmt.Errorf("flag '--min-size-mb' must be equal or lower than '--max-size-mb'") logger.Error().Str("error", err.Error()).Msg("an error occured while validating flags") return err } if !utils.Contains(ValidSortByOpts, cleanOpts.SortBy) { err := fmt.Errorf("no such '--sort-by' option called %s, valid options are %v", cleanOpts.SortBy, ValidSortByOpts) logger.Error().Str("error", err.Error()).Msg("an error occurred while validating flags") return err } logger.Info().Msg("trying to search files on target bucket") if err := cleaner.StartCleaning(svc, promptRunner, cleanOpts, logger); err != nil { logger.Error().Str("error", err.Error()).Msg("an error occurred while cleaning") return err } return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.