Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PutLifecycleConfiguration's Prefix field #228

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions internal/rgw/lifecycleconfig_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ func GenerateLifecycleRules(in []v1alpha1.LifecycleRule) []types.LifecycleRule {
ID: local.ID,
Status: types.ExpirationStatus(local.Status),
}
if local.Prefix != nil {
rule.Prefix = local.Prefix //nolint:staticcheck // Support deprecated field.
}
if local.AbortIncompleteMultipartUpload != nil && local.AbortIncompleteMultipartUpload.DaysAfterInitiation != nil {
rule.AbortIncompleteMultipartUpload = &types.AbortIncompleteMultipartUpload{
DaysAfterInitiation: local.AbortIncompleteMultipartUpload.DaysAfterInitiation,
Expand Down Expand Up @@ -89,8 +86,14 @@ func GenerateLifecycleRules(in []v1alpha1.LifecycleRule) []types.LifecycleRule {
rule.Transitions = append(rule.Transitions, transition)
}
}
// This is done because S3 expects an empty filter, and never nil
rule.Filter = &types.LifecycleRuleFilterMemberPrefix{}

if local.Prefix != nil {
rule.Prefix = local.Prefix //nolint:staticcheck // Support deprecated field.
} else {
// This is done because S3 expects an empty filter, and never nil if Prefix is not set.
rule.Filter = &types.LifecycleRuleFilterMemberPrefix{}
}

//nolint:nestif // Multiple checks required
if local.Filter != nil {
if local.Filter.Prefix != nil {
Expand Down
2 changes: 0 additions & 2 deletions internal/rgw/lifecycleconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestGenerateLifecycleConfigurationInput(t *testing.T) {
Expiration: &types.LifecycleExpiration{
Days: &days365,
},
Filter: &types.LifecycleRuleFilterMemberPrefix{},
},
},
},
Expand Down Expand Up @@ -148,7 +147,6 @@ func TestGenerateLifecycleConfigurationInput(t *testing.T) {
Expiration: &types.LifecycleExpiration{
Days: &days3650,
},
Filter: &types.LifecycleRuleFilterMemberPrefix{},
Transitions: []types.Transition{
{
Days: &days365,
Expand Down
Loading