MCPcopy
hub / github.com/minio/minio-go / SetBucketLifecycle

Method SetBucketLifecycle

api-bucket-lifecycle.go:34–52  ·  view source on GitHub ↗

SetBucketLifecycle set the lifecycle on an existing bucket.

(ctx context.Context, bucketName string, config *lifecycle.Configuration)

Source from the content-addressed store, hash-verified

32
33// SetBucketLifecycle set the lifecycle on an existing bucket.
34func (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.
55func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte) error {

Callers 1

mainFunction · 0.80

Calls 5

removeBucketLifecycleMethod · 0.95
putBucketLifecycleMethod · 0.95
CheckValidBucketNameFunction · 0.92
MarshalMethod · 0.65
EmptyMethod · 0.45

Tested by

no test coverage detected