diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 9493f2e1f3..2ded20b9c6 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1716,7 +1716,7 @@ func (c *S3Client) Stat(ctx context.Context, opts StatOptions) (*ClientContent, nonRecursive := false maxKeys := 1 - for objectStat := range c.listObjectWrapper(ctx, bucket, path, nonRecursive, opts.timeRef, false, false, false, maxKeys, opts.isZip) { + for objectStat := range c.listObjectWrapper(ctx, bucket, path, nonRecursive, opts.timeRef, opts.includeVersions, opts.includeVersions, false, maxKeys, opts.isZip) { if objectStat.Err != nil { return nil, probe.NewError(objectStat.Err) } diff --git a/cmd/client.go b/cmd/client.go index 351e7b388c..82d3471bed 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -71,6 +71,7 @@ type StatOptions struct { sse encrypt.ServerSide timeRef time.Time versionID string + includeVersions bool isZip bool ignoreBucketExists bool } diff --git a/cmd/find-main.go b/cmd/find-main.go index a153145e43..4a7d66d7a6 100644 --- a/cmd/find-main.go +++ b/cmd/find-main.go @@ -207,21 +207,21 @@ 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 - withOlderVersions 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 + matchMeta map[string]*regexp.Regexp + matchTags map[string]*regexp.Regexp // Internal values targetAlias string @@ -295,25 +295,25 @@ 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"), - withOlderVersions: 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, + 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"), }) } diff --git a/cmd/find.go b/cmd/find.go index 550d9d2d3e..11c7f276ef 100644 --- a/cmd/find.go +++ b/cmd/find.go @@ -272,7 +272,7 @@ func doFind(ctxCtx context.Context, ctx *findContext) error { defer watchFind(ctxCtx, ctx) lstOptions := ListOptions{ - WithOlderVersions: ctx.withOlderVersions, + WithOlderVersions: ctx.withVersions, WithDeleteMarkers: false, Recursive: true, ShowDir: DirFirst, diff --git a/cmd/legalhold-info.go b/cmd/legalhold-info.go index be376cf2eb..3af0c5c104 100644 --- a/cmd/legalhold-info.go +++ b/cmd/legalhold-info.go @@ -129,7 +129,7 @@ func (l legalHoldInfoMessage) JSON() string { } // showLegalHoldInfo - show legalhold for one or many objects within a given prefix, with or without versioning -func showLegalHoldInfo(ctx context.Context, urlStr, versionID string, timeRef time.Time, withOlderVersions, recursive bool) error { +func showLegalHoldInfo(ctx context.Context, urlStr, versionID string, timeRef time.Time, withVersions, recursive bool) error { clnt, err := newClient(urlStr) if err != nil { fatalIf(err.Trace(), "Unable to parse the provided url.") @@ -142,7 +142,7 @@ func showLegalHoldInfo(ctx context.Context, urlStr, versionID string, timeRef ti } prefixPath = strings.TrimPrefix(prefixPath, "./") - if !recursive && !withOlderVersions { + if !recursive && !withVersions { lhold, err := clnt.GetObjectLegalHold(ctx, versionID) if err != nil { fatalIf(err.Trace(urlStr), "Failed to show legal hold information of `"+urlStr+"`.") @@ -167,7 +167,7 @@ func showLegalHoldInfo(ctx context.Context, urlStr, versionID string, timeRef ti objectsFound := false lstOptions := ListOptions{Recursive: recursive, ShowDir: DirNone} if !timeRef.IsZero() { - lstOptions.WithOlderVersions = withOlderVersions + lstOptions.WithOlderVersions = withVersions lstOptions.TimeRef = timeRef } for content := range clnt.List(ctx, lstOptions) { diff --git a/cmd/legalhold-set.go b/cmd/legalhold-set.go index 427c4e73cc..f6b8e6aedc 100644 --- a/cmd/legalhold-set.go +++ b/cmd/legalhold-set.go @@ -82,7 +82,7 @@ EXAMPLES: } // setLegalHold - Set legalhold for all objects within a given prefix. -func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Time, withOlderVersions, recursive bool, lhold minio.LegalHoldStatus) error { +func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Time, withVersions, recursive bool, lhold minio.LegalHoldStatus) error { clnt, err := newClient(urlStr) if err != nil { fatalIf(err.Trace(), "Unable to parse the provided url.") @@ -95,7 +95,7 @@ func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Ti } prefixPath = strings.TrimPrefix(prefixPath, "./") - if !recursive && !withOlderVersions { + if !recursive && !withVersions { err = clnt.PutObjectLegalHold(ctx, versionID, lhold) if err != nil { errorIf(err.Trace(urlStr), "Failed to set legal hold on `"+urlStr+"` successfully") @@ -119,7 +119,7 @@ func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Ti objectsFound := false lstOptions := ListOptions{Recursive: recursive, ShowDir: DirNone} if !timeRef.IsZero() { - lstOptions.WithOlderVersions = withOlderVersions + lstOptions.WithOlderVersions = withVersions lstOptions.TimeRef = timeRef } for content := range clnt.List(ctx, lstOptions) { diff --git a/cmd/ls-main.go b/cmd/ls-main.go index 8cafa131dd..ade7868ee8 100644 --- a/cmd/ls-main.go +++ b/cmd/ls-main.go @@ -170,24 +170,24 @@ func checkListSyntax(cliCtx *cli.Context) ([]string, doListOptions) { isRecursive := cliCtx.Bool("recursive") isIncomplete := cliCtx.Bool("incomplete") - withOlderVersions := cliCtx.Bool("versions") + withVersions := cliCtx.Bool("versions") isSummary := cliCtx.Bool("summarize") listZip := cliCtx.Bool("zip") timeRef := parseRewindFlag(cliCtx.String("rewind")) - if listZip && (withOlderVersions || !timeRef.IsZero()) { + if listZip && (withVersions || !timeRef.IsZero()) { fatalIf(errInvalidArgument().Trace(args...), "Zip file listing can only be performed on the latest version") } storageClasss := cliCtx.String("storage-class") opts := doListOptions{ - timeRef: timeRef, - isRecursive: isRecursive, - isIncomplete: isIncomplete, - isSummary: isSummary, - withOlderVersions: withOlderVersions, - listZip: listZip, - filter: storageClasss, + timeRef: timeRef, + isRecursive: isRecursive, + isIncomplete: isIncomplete, + isSummary: isSummary, + withVersions: withVersions, + listZip: listZip, + filter: storageClasss, } return args, opts } @@ -218,7 +218,7 @@ func mainList(cliCtx *cli.Context) error { fatalIf(err.Trace(targetURL), "Unable to initialize target `"+targetURL+"`.") if !strings.HasSuffix(targetURL, string(clnt.GetURL().Separator)) { var st *ClientContent - st, err = clnt.Stat(ctx, StatOptions{incomplete: opts.isIncomplete}) + st, err = clnt.Stat(ctx, StatOptions{incomplete: opts.isIncomplete, includeVersions: opts.withVersions}) if st != nil && err == nil && st.Type.IsDir() { targetURL = targetURL + string(clnt.GetURL().Separator) clnt, err = newClient(targetURL) diff --git a/cmd/ls.go b/cmd/ls.go index dde7e418e0..fe23bfc6ef 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -207,13 +207,13 @@ func printObjectVersions(clntURL ClientURL, ctntVersions []*ClientContent, print } type doListOptions struct { - timeRef time.Time - isRecursive bool - isIncomplete bool - isSummary bool - withOlderVersions bool - listZip bool - filter string + timeRef time.Time + isRecursive bool + isIncomplete bool + isSummary bool + withVersions bool + listZip bool + filter string } // doList - list all entities inside a folder. @@ -230,7 +230,7 @@ func doList(ctx context.Context, clnt Client, o doListOptions) error { Recursive: o.isRecursive, Incomplete: o.isIncomplete, TimeRef: o.timeRef, - WithOlderVersions: o.withOlderVersions || !o.timeRef.IsZero(), + WithOlderVersions: o.withVersions || !o.timeRef.IsZero(), WithDeleteMarkers: true, ShowDir: DirNone, ListZip: o.listZip, @@ -247,7 +247,7 @@ func doList(ctx context.Context, clnt Client, o doListOptions) error { if lastPath != content.URL.Path { // Print any object in the current list before reinitializing it - printObjectVersions(clnt.GetURL(), perObjectVersions, o.withOlderVersions) + printObjectVersions(clnt.GetURL(), perObjectVersions, o.withVersions) lastPath = content.URL.Path perObjectVersions = []*ClientContent{} } @@ -257,7 +257,7 @@ func doList(ctx context.Context, clnt Client, o doListOptions) error { totalObjects++ } - printObjectVersions(clnt.GetURL(), perObjectVersions, o.withOlderVersions) + printObjectVersions(clnt.GetURL(), perObjectVersions, o.withVersions) if o.isSummary { printMsg(summaryMessage{ diff --git a/cmd/retention-clear.go b/cmd/retention-clear.go index a787c52260..3d076cadea 100644 --- a/cmd/retention-clear.go +++ b/cmd/retention-clear.go @@ -114,8 +114,8 @@ func parseClearRetentionArgs(cliCtx *cli.Context) (target, versionID string, tim } // Clear Retention for one object/version or many objects within a given prefix, bypass governance is always enabled -func clearRetention(ctx context.Context, target, versionID string, timeRef time.Time, withOlderVersions, isRecursive bool) error { - return applyRetention(ctx, lockOpClear, target, versionID, timeRef, withOlderVersions, isRecursive, "", 0, minio.Days, true) +func clearRetention(ctx context.Context, target, versionID string, timeRef time.Time, withVersions, isRecursive bool) error { + return applyRetention(ctx, lockOpClear, target, versionID, timeRef, withVersions, isRecursive, "", 0, minio.Days, true) } func clearBucketLock(urlStr string) error { diff --git a/cmd/retention-common.go b/cmd/retention-common.go index 68c120e608..d8ba4329bd 100644 --- a/cmd/retention-common.go +++ b/cmd/retention-common.go @@ -178,7 +178,7 @@ func fatalIfBucketLockNotSupported(ctx context.Context, aliasedURL string) { } // Apply Retention for one object/version or many objects within a given prefix. -func applyRetention(ctx context.Context, op lockOpType, target, versionID string, timeRef time.Time, withOlderVersions, isRecursive bool, +func applyRetention(ctx context.Context, op lockOpType, target, versionID string, timeRef time.Time, withVersions, isRecursive bool, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit, bypassGovernance bool, ) error { clnt, err := newClient(target) @@ -207,7 +207,7 @@ func applyRetention(ctx context.Context, op lockOpType, target, versionID string } alias, urlStr, _ := mustExpandAlias(target) - if versionID != "" || !isRecursive && !withOlderVersions { + if versionID != "" || !isRecursive && !withVersions { err := setRetentionSingle(ctx, op, alias, urlStr, versionID, mode, until, bypassGovernance) fatalIf(err.Trace(), "Unable to set retention on `%s`", target) return nil @@ -215,7 +215,7 @@ func applyRetention(ctx context.Context, op lockOpType, target, versionID string lstOptions := ListOptions{Recursive: isRecursive, ShowDir: DirNone} if !timeRef.IsZero() { - lstOptions.WithOlderVersions = withOlderVersions + lstOptions.WithOlderVersions = withVersions lstOptions.WithDeleteMarkers = true lstOptions.TimeRef = timeRef } diff --git a/cmd/retention-info.go b/cmd/retention-info.go index c7e92bb9ae..40c8cc881f 100644 --- a/cmd/retention-info.go +++ b/cmd/retention-info.go @@ -300,7 +300,7 @@ func infoRetentionSingle(ctx context.Context, alias, url, versionID string, list } // Get Retention for one object/version or many objects within a given prefix. -func getRetention(ctx context.Context, target, versionID string, timeRef time.Time, withOlderVersions, isRecursive bool) error { +func getRetention(ctx context.Context, target, versionID string, timeRef time.Time, withVersions, isRecursive bool) error { clnt, err := newClient(target) if err != nil { fatalIf(err.Trace(), "Unable to parse the provided url.") @@ -314,7 +314,7 @@ func getRetention(ctx context.Context, target, versionID string, timeRef time.Ti } alias, urlStr, _ := mustExpandAlias(target) - if versionID != "" || !isRecursive && !withOlderVersions { + if versionID != "" || !isRecursive && !withVersions { err := infoRetentionSingle(ctx, alias, urlStr, versionID, false) if err != nil { if _, ok := err.ToGoError().(ObjectNameEmpty); ok { @@ -327,7 +327,7 @@ func getRetention(ctx context.Context, target, versionID string, timeRef time.Ti lstOptions := ListOptions{Recursive: isRecursive, ShowDir: DirNone} if !timeRef.IsZero() { - lstOptions.WithOlderVersions = withOlderVersions + lstOptions.WithOlderVersions = withVersions lstOptions.WithDeleteMarkers = true lstOptions.TimeRef = timeRef } diff --git a/cmd/retention-set.go b/cmd/retention-set.go index af8a7a75d1..1218841dba 100644 --- a/cmd/retention-set.go +++ b/cmd/retention-set.go @@ -128,10 +128,10 @@ func parseSetRetentionArgs(cliCtx *cli.Context) (target, versionID string, recur } // Set Retention for one object/version or many objects within a given prefix. -func setRetention(ctx context.Context, target, versionID string, timeRef time.Time, withOlderVersions, isRecursive bool, +func setRetention(ctx context.Context, target, versionID string, timeRef time.Time, withVersions, isRecursive bool, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit, bypassGovernance bool, ) error { - return applyRetention(ctx, lockOpSet, target, versionID, timeRef, withOlderVersions, isRecursive, mode, validity, unit, bypassGovernance) + return applyRetention(ctx, lockOpSet, target, versionID, timeRef, withVersions, isRecursive, mode, validity, unit, bypassGovernance) } func setBucketLock(urlStr string, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit) error { diff --git a/cmd/tag-list.go b/cmd/tag-list.go index fb38ffd397..af4f480fbe 100644 --- a/cmd/tag-list.go +++ b/cmd/tag-list.go @@ -147,14 +147,14 @@ func (t tagListMessage) String() string { } // parseTagListSyntax performs command-line input validation for tag list command. -func parseTagListSyntax(ctx *cli.Context) (targetURL, versionID string, timeRef time.Time, withOlderVersions, recursive bool) { +func parseTagListSyntax(ctx *cli.Context) (targetURL, versionID string, timeRef time.Time, withVersions, recursive bool) { if len(ctx.Args()) != 1 { showCommandHelpAndExit(ctx, globalErrorExitStatus) } targetURL = ctx.Args().Get(0) versionID = ctx.String("version-id") - withOlderVersions = ctx.Bool("versions") + withVersions = ctx.Bool("versions") rewind := ctx.String("rewind") recursive = ctx.Bool("recursive") diff --git a/cmd/tree-main.go b/cmd/tree-main.go index 78c3c918b9..86e50887a8 100644 --- a/cmd/tree-main.go +++ b/cmd/tree-main.go @@ -294,13 +294,13 @@ func mainTree(cliCtx *cli.Context) error { clnt, err := newClientFromAlias(targetAlias, targetURL) fatalIf(err.Trace(targetURL), "Unable to initialize target `"+targetURL+"`.") opts := doListOptions{ - timeRef: timeRef, - isRecursive: true, - isIncomplete: false, - isSummary: false, - withOlderVersions: false, - listZip: false, - filter: "*", + timeRef: timeRef, + isRecursive: true, + isIncomplete: false, + isSummary: false, + withVersions: false, + listZip: false, + filter: "*", } if e := doList(ctx, clnt, opts); e != nil { cErr = e