fallback to bucket retention info for only bucket names (#3860)
This commit is contained in:
@@ -2197,6 +2197,9 @@ func (c *S3Client) PutObjectRetention(ctx context.Context, versionID string, mod
|
||||
// GetObjectRetention - Get object retention for a given object.
|
||||
func (c *S3Client) GetObjectRetention(ctx context.Context, versionID string) (minio.RetentionMode, time.Time, *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if object == "" {
|
||||
return "", time.Time{}, probe.NewError(ObjectNameEmpty{}).Trace(c.GetURL().String())
|
||||
}
|
||||
modePtr, untilPtr, e := c.api.GetObjectRetention(ctx, bucket, object, versionID)
|
||||
if e != nil {
|
||||
return "", time.Time{}, probe.NewError(e).Trace(c.GetURL().String())
|
||||
|
||||
+10
-4
@@ -87,7 +87,7 @@ EXAMPLES:
|
||||
$ {{.HelpName}} myminio/mybucket/prefix --recursive --versions
|
||||
|
||||
5. Show default lock retention configuration for a bucket
|
||||
$ {{.HelpName}} --default myminio/mybucket/
|
||||
$ {{.HelpName}} myminio/mybucket/ --default
|
||||
`}
|
||||
|
||||
func parseInfoRetentionArgs(cliCtx *cli.Context) (target, versionID string, recursive bool, timeRef time.Time, withVersions, defaultMode bool) {
|
||||
@@ -273,9 +273,11 @@ func infoRetentionSingle(ctx context.Context, alias, url, versionID string, list
|
||||
if err != nil {
|
||||
errResp := minio.ToErrorResponse(err.ToGoError())
|
||||
if errResp.Code != "NoSuchObjectLockConfiguration" {
|
||||
msg.SetErr(err.ToGoError())
|
||||
msg.SetStatus("failure")
|
||||
printMsg(msg)
|
||||
if _, ok := err.ToGoError().(ObjectNameEmpty); !ok {
|
||||
msg.SetErr(err.ToGoError())
|
||||
msg.SetStatus("failure")
|
||||
printMsg(msg)
|
||||
}
|
||||
return err
|
||||
}
|
||||
err = nil
|
||||
@@ -307,6 +309,10 @@ func getRetention(ctx context.Context, target, versionID string, timeRef time.Ti
|
||||
if versionID != "" || !isRecursive && !withOlderVersions {
|
||||
err := infoRetentionSingle(ctx, alias, urlStr, versionID, false)
|
||||
if err != nil {
|
||||
if _, ok := err.ToGoError().(ObjectNameEmpty); ok {
|
||||
console.Infoln("no object name specified, showing bucket default retention mode instead")
|
||||
return showBucketLock(target)
|
||||
}
|
||||
return exitStatus(globalErrorExitStatus)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user