diff --git a/pkg/obc/provisioner.go b/pkg/obc/provisioner.go index 94759dae7..a3385b487 100644 --- a/pkg/obc/provisioner.go +++ b/pkg/obc/provisioner.go @@ -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,