Skip to content

Commit

Permalink
Fix replication policy deletion (#1325)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben <[email protected]>
  • Loading branch information
Neon-White authored Mar 19, 2024
1 parent 6221ee6 commit fd48560
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/obc/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,18 +701,19 @@ func (r *BucketRequest) putBucketTagging() error {
func PrepareReplicationParams(bucketName string, replicationPolicy string, update bool) (*nb.BucketReplicationParams, *nb.DeleteBucketReplicationParams, error) {

var replicationRules nb.ReplicationPolicy
err := json.Unmarshal([]byte(replicationPolicy), &replicationRules)
if err != nil {
return nil, nil, fmt.Errorf("PrepareReplicationParams: Failed to parse replication json %q: %v", replicationRules, err)
}
deleteReplicationParams := &nb.DeleteBucketReplicationParams{
Name: bucketName,
}

if replicationPolicy == "" && update {
deleteReplicationParams := &nb.DeleteBucketReplicationParams{
Name: bucketName,
}
return nil, deleteReplicationParams, nil
}

err := json.Unmarshal([]byte(replicationPolicy), &replicationRules)
if err != nil {
return nil, nil, fmt.Errorf("PrepareReplicationParams: Failed to parse replication json %q: %v", replicationRules, err)
}

replicationParams := &nb.BucketReplicationParams{
Name: bucketName,
ReplicationPolicy: replicationRules,
Expand Down

0 comments on commit fd48560

Please sign in to comment.