Default DeleteReplication rule status if unspecified. (#15301)

Since this is a MinIO specific extension in the replication config,
default this to Disabled to allow other sdks to be used to configure
replication rules.

Co-authored-by: Poorna Krishnamoorthy <poorna@minio.io>
This commit is contained in:
Poorna 2022-07-14 16:27:09 -07:00 committed by GitHub
parent bb4b143f3b
commit 53cc561048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -62,6 +62,12 @@ func ParseConfig(reader io.Reader) (*Config, error) {
},
}
}
// Default DeleteReplication to disabled if unset.
if len(config.Rules[i].DeleteReplication.Status) == 0 {
config.Rules[i].DeleteReplication = DeleteReplication{
Status: Disabled,
}
}
}
return &config, nil
}

View File

@ -38,13 +38,13 @@ func TestParseAndValidateReplicationConfig(t *testing.T) {
expectedParsingErr: nil,
expectedValidationErr: errInvalidDeleteMarkerReplicationStatus,
},
// 2 Invalid delete replication status in replication config
// 2 No delete replication status in replication config
{
inputConfig: `<ReplicationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Role>arn:aws:iam::AcctID:role/role-name</Role><Rule><Status>Enabled</Status><DeleteMarkerReplication><Status>Disabled</Status></DeleteMarkerReplication><Prefix>key-prefix</Prefix><Destination><Bucket>arn:aws:s3:::destinationbucket</Bucket></Destination></Rule></ReplicationConfiguration>`,
destBucket: "destinationbucket",
sameTarget: false,
expectedParsingErr: nil,
expectedValidationErr: errDeleteReplicationMissing,
expectedValidationErr: nil,
},
// 3 valid replication config
{