Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ValidSortByOpts = []string{"size", "lastModificationDate"} CleanCmd = &cobra.Command{ Use: "clean", Short: "finds and clears desired files by a pre-configured rule set", SilenceUsage: false, 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 { var rootOpts *rootopts.RootOptions svc, rootOpts, logger, confirmRunner = utils.PrepareConstants(cmd) cleanOpts.RootOptions = rootOpts if err := utils.CheckArgs(args, 0); err != nil { logger.Error().Msg(err.Error()) return err } 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, confirmRunner, 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.