SetBucketReplication sets the replication configuration on an existing bucket. If the provided configuration is empty, this method removes the existing replication configuration. Parameters: - ctx: Context for request cancellation and timeout - bucketName: Name of the bucket - cfg: Replication conf
(ctx context.Context, bucketName string, cfg replication.Config)
| 53 | // |
| 54 | // Returns an error if the operation fails. |
| 55 | func (c *Client) SetBucketReplication(ctx context.Context, bucketName string, cfg replication.Config) error { |
| 56 | // Input validation. |
| 57 | if err := s3utils.CheckValidBucketName(bucketName); err != nil { |
| 58 | return err |
| 59 | } |
| 60 | |
| 61 | // If replication is empty then delete it. |
| 62 | if cfg.Empty() { |
| 63 | return c.removeBucketReplication(ctx, bucketName) |
| 64 | } |
| 65 | // Save the updated replication. |
| 66 | return c.putBucketReplication(ctx, bucketName, cfg) |
| 67 | } |
| 68 | |
| 69 | // Saves a new bucket replication. |
| 70 | func (c *Client) putBucketReplication(ctx context.Context, bucketName string, cfg replication.Config) error { |
no test coverage detected