Skip to content

Commit

Permalink
Support replication of deleted ILM expiry rules
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 23, 2023
1 parent 4c868ef commit 74a6845
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api-bucket-lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ 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) error {
func (c *Client) SetBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration, expiryRuleRemoved bool) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
Expand All @@ -48,15 +49,16 @@ func (c *Client) SetBucketLifecycle(ctx context.Context, bucketName string, conf
}

// Save the updated lifecycle.
return c.putBucketLifecycle(ctx, bucketName, buf)
return c.putBucketLifecycle(ctx, bucketName, buf, expiryRuleRemoved)
}

// Saves a new bucket lifecycle.
func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte) error {
func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte, expiryRuleRemoved bool) 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

0 comments on commit 74a6845

Please sign in to comment.