Skip to content

Commit

Permalink
Incorporated review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat committed Oct 30, 2023
1 parent de99c25 commit 6fbe029
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions api-bucket-lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"time"

"github.com/minio/minio-go/v7/pkg/lifecycle"
"github.com/minio/minio-go/v7/pkg/s3utils"
)

// 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
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion examples/s3/setbucketlifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/lifecycle/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6fbe029

Please sign in to comment.