Add DeleteAll with expiry days non zero value only (#19095)

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
Shubhendu 2024-02-22 01:58:34 +05:30 committed by GitHub
parent 92180bc793
commit 56887f3208
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -28,6 +28,7 @@ var (
errLifecycleInvalidExpiration = Errorf("Exactly one of Days (positive integer) or Date (positive ISO 8601 format) should be present inside Expiration.") errLifecycleInvalidExpiration = Errorf("Exactly one of Days (positive integer) or Date (positive ISO 8601 format) should be present inside Expiration.")
errLifecycleInvalidDeleteMarker = Errorf("Delete marker cannot be specified with Days or Date in a Lifecycle Expiration Policy") errLifecycleInvalidDeleteMarker = Errorf("Delete marker cannot be specified with Days or Date in a Lifecycle Expiration Policy")
errLifecycleDateNotMidnight = Errorf("'Date' must be at midnight GMT") errLifecycleDateNotMidnight = Errorf("'Date' must be at midnight GMT")
errLifecycleInvalidDeleteAll = Errorf("Days (positive integer) should be present inside Expiration with ExpiredObjectAllVersions.")
) )
// ExpirationDays is a type alias to unmarshal Days in Expiration // ExpirationDays is a type alias to unmarshal Days in Expiration
@ -186,6 +187,11 @@ func (e Expiration) Validate() error {
return errLifecycleInvalidExpiration return errLifecycleInvalidExpiration
} }
// DeleteAll set without expiration days
if e.DeleteAll.set && e.IsDaysNull() {
return errLifecycleInvalidDeleteAll
}
return nil return nil
} }

View File

@ -106,7 +106,7 @@ func TestInvalidExpiration(t *testing.T) {
<Date>2019-04-20T00:00:00Z</Date> <Date>2019-04-20T00:00:00Z</Date>
<ExpiredObjectAllVersions>true</ExpiredObjectAllVersions> <ExpiredObjectAllVersions>true</ExpiredObjectAllVersions>
</Expiration>`, </Expiration>`,
expectedErr: nil, expectedErr: errLifecycleInvalidDeleteAll,
}, },
} }
for i, tc := range validationTestCases { for i, tc := range validationTestCases {