From 6fbe0293a7b3333a6a056ce99abefc29f97aea95 Mon Sep 17 00:00:00 2001 From: Shubhendu Ram Tripathi Date: Mon, 30 Oct 2023 13:17:21 +0530 Subject: [PATCH] Incorporated review comments Signed-off-by: Shubhendu Ram Tripathi --- api-bucket-lifecycle.go | 8 +++----- examples/s3/setbucketlifecycle.go | 2 +- pkg/lifecycle/lifecycle.go | 5 +++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/api-bucket-lifecycle.go b/api-bucket-lifecycle.go index 7980869db..fec5cece5 100644 --- a/api-bucket-lifecycle.go +++ b/api-bucket-lifecycle.go @@ -24,7 +24,6 @@ import ( "io" "net/http" "net/url" - "strconv" "time" "github.com/minio/minio-go/v7/pkg/lifecycle" @@ -32,7 +31,7 @@ import ( ) // SetBucketLifecycle set the lifecycle on an existing bucket. -func (c *Client) SetBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration, expiryRuleRemoved bool) error { +func (c *Client) SetBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err @@ -49,16 +48,15 @@ func (c *Client) SetBucketLifecycle(ctx context.Context, bucketName string, conf } // Save the updated lifecycle. - return c.putBucketLifecycle(ctx, bucketName, buf, expiryRuleRemoved) + return c.putBucketLifecycle(ctx, bucketName, buf) } // Saves a new bucket lifecycle. -func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte, expiryRuleRemoved bool) error { +func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte) error { // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("lifecycle", "") - urlValues.Set("expiryRuleRemoved", strconv.FormatBool(expiryRuleRemoved)) // Content-length is mandatory for put lifecycle request reqMetadata := requestMetadata{ diff --git a/examples/s3/setbucketlifecycle.go b/examples/s3/setbucketlifecycle.go index fc7acb6f5..a363d5cde 100644 --- a/examples/s3/setbucketlifecycle.go +++ b/examples/s3/setbucketlifecycle.go @@ -59,7 +59,7 @@ func main() { }, }, } - err = s3Client.SetBucketLifecycle(context.Background(), "my-bucketname", config, false) + err = s3Client.SetBucketLifecycle(context.Background(), "my-bucketname", config) if err != nil { log.Fatalln(err) } diff --git a/pkg/lifecycle/lifecycle.go b/pkg/lifecycle/lifecycle.go index 830061b8e..eacf5d7ba 100644 --- a/pkg/lifecycle/lifecycle.go +++ b/pkg/lifecycle/lifecycle.go @@ -449,8 +449,9 @@ type Rule struct { // Configuration is a collection of Rule objects. type Configuration struct { - XMLName xml.Name `xml:"LifecycleConfiguration,omitempty" json:"-"` - Rules []Rule `xml:"Rule"` + XMLName xml.Name `xml:"LifecycleConfiguration,omitempty" json:"-"` + Rules []Rule `xml:"Rule"` + ExpiryRuleRemoved bool `xml:"ExpiryRuleRemoved,omitempty" json:"-"` } // Empty check if lifecycle configuration is empty