SetBucketLifecycle set the lifecycle on an existing bucket.
(ctx context.Context, bucketName string, config *lifecycle.Configuration)
| 32 | |
| 33 | // SetBucketLifecycle set the lifecycle on an existing bucket. |
| 34 | func (c *Client) SetBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration) error { |
| 35 | // Input validation. |
| 36 | if err := s3utils.CheckValidBucketName(bucketName); err != nil { |
| 37 | return err |
| 38 | } |
| 39 | |
| 40 | // If lifecycle is empty then delete it. |
| 41 | if config.Empty() { |
| 42 | return c.removeBucketLifecycle(ctx, bucketName) |
| 43 | } |
| 44 | |
| 45 | buf, err := xml.Marshal(config) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | // Save the updated lifecycle. |
| 51 | return c.putBucketLifecycle(ctx, bucketName, buf) |
| 52 | } |
| 53 | |
| 54 | // Saves a new bucket lifecycle. |
| 55 | func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte) error { |
no test coverage detected