Skip to content

Commit

Permalink
Add --with-delete-marker flag to toggle the listing of delete markers…
Browse files Browse the repository at this point in the history
…. Defaults to false
  • Loading branch information
allanrogerr committed Nov 20, 2024
1 parent 3efbf7b commit 4ca10b6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 36 deletions.
80 changes: 45 additions & 35 deletions cmd/find-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ var (
Name: "versions",
Usage: "include all objects versions",
},
cli.BoolFlag{
Name: "with-delete-marker",
Usage: "include delete markers when used with the `versions` flag",
},
cli.StringFlag{
Name: "name",
Usage: "find object names matching wildcard pattern",
Expand Down Expand Up @@ -207,21 +211,22 @@ func checkFindSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[stri
// ease of repurposing.
type findContext struct {
*cli.Context
execCmd string
ignorePattern string
namePattern string
pathPattern string
regexPattern *regexp.Regexp
maxDepth uint
printFmt string
olderThan string
newerThan string
largerSize uint64
smallerSize uint64
watch bool
withVersions bool
matchMeta map[string]*regexp.Regexp
matchTags map[string]*regexp.Regexp
execCmd string
ignorePattern string
namePattern string
pathPattern string
regexPattern *regexp.Regexp
maxDepth uint
printFmt string
olderThan string
newerThan string
largerSize uint64
smallerSize uint64
watch bool
withVersions bool
withDeleteMarkers bool
matchMeta map[string]*regexp.Regexp
matchTags map[string]*regexp.Regexp

// Internal values
targetAlias string
Expand Down Expand Up @@ -281,6 +286,10 @@ func mainFind(cliCtx *cli.Context) error {

// Get --versions flag
withVersions := cliCtx.Bool("versions")
withDeleteMarkers := false
if withVersions {
withDeleteMarkers = cliCtx.Bool("with-delete-marker")
}

targetAlias, _, hostCfg, err := expandAlias(args[0])
fatalIf(err.Trace(args[0]), "Unable to expand alias.")
Expand All @@ -295,25 +304,26 @@ func mainFind(cliCtx *cli.Context) error {
}

return doFind(ctx, &findContext{
Context: cliCtx,
maxDepth: cliCtx.Uint("maxdepth"),
execCmd: cliCtx.String("exec"),
printFmt: cliCtx.String("print"),
namePattern: cliCtx.String("name"),
pathPattern: cliCtx.String("path"),
regexPattern: regMatch,
ignorePattern: cliCtx.String("ignore"),
withVersions: withVersions,
olderThan: olderThan,
newerThan: newerThan,
largerSize: largerSize,
smallerSize: smallerSize,
watch: cliCtx.Bool("watch"),
targetAlias: targetAlias,
targetURL: args[0],
targetFullURL: targetFullURL,
clnt: clnt,
matchMeta: getRegexMap(cliCtx, "metadata"),
matchTags: getRegexMap(cliCtx, "tags"),
Context: cliCtx,
maxDepth: cliCtx.Uint("maxdepth"),
execCmd: cliCtx.String("exec"),
printFmt: cliCtx.String("print"),
namePattern: cliCtx.String("name"),
pathPattern: cliCtx.String("path"),
regexPattern: regMatch,
ignorePattern: cliCtx.String("ignore"),
withVersions: withVersions,
withDeleteMarkers: withDeleteMarkers,
olderThan: olderThan,
newerThan: newerThan,
largerSize: largerSize,
smallerSize: smallerSize,
watch: cliCtx.Bool("watch"),
targetAlias: targetAlias,
targetURL: args[0],
targetFullURL: targetFullURL,
clnt: clnt,
matchMeta: getRegexMap(cliCtx, "metadata"),
matchTags: getRegexMap(cliCtx, "tags"),
})
}
2 changes: 1 addition & 1 deletion cmd/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func doFind(ctxCtx context.Context, ctx *findContext) error {

lstOptions := ListOptions{
WithOlderVersions: ctx.withVersions,
WithDeleteMarkers: true,
WithDeleteMarkers: ctx.withDeleteMarkers,
Recursive: true,
ShowDir: DirFirst,
WithMetadata: len(ctx.matchMeta) > 0 || len(ctx.matchTags) > 0,
Expand Down

0 comments on commit 4ca10b6

Please sign in to comment.