Skip to content

Commit

Permalink
ignore IDs in comparison
Browse files Browse the repository at this point in the history
Signed-off-by: smcavallo <smcavallo@hotmail.com>
  • Loading branch information
smcavallo committed Nov 9, 2021
1 parent 6d585be commit 05634a7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/s3/bucket/notificationConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func IsNotificationConfigurationUpToDate(cr *v1beta1.NotificationConfiguration,
sortTopic(generated.TopicConfigurations)
sortTopic(external.TopicConfigurations)

if cmp.Equal(external.LambdaFunctionConfigurations, generated.LambdaFunctionConfigurations, cmpopts.IgnoreTypes(document.NoSerde{}), cmpopts.EquateEmpty()) &&
cmp.Equal(external.QueueConfigurations, generated.QueueConfigurations, cmpopts.IgnoreTypes(document.NoSerde{}), cmpopts.EquateEmpty()) &&
cmp.Equal(external.TopicConfigurations, generated.TopicConfigurations, cmpopts.IgnoreTypes(document.NoSerde{}), cmpopts.EquateEmpty()) {
if cmp.Equal(external.LambdaFunctionConfigurations, generated.LambdaFunctionConfigurations, cmpopts.IgnoreTypes(document.NoSerde{}, types.LambdaFunctionConfiguration{}.Id), cmpopts.EquateEmpty()) &&
cmp.Equal(external.QueueConfigurations, generated.QueueConfigurations, cmpopts.IgnoreTypes(document.NoSerde{}, types.QueueConfiguration{}.Id), cmpopts.EquateEmpty()) &&
cmp.Equal(external.TopicConfigurations, generated.TopicConfigurations, cmpopts.IgnoreTypes(document.NoSerde{}, types.TopicConfiguration{}.Id), cmpopts.EquateEmpty()) {
return Updated, nil
}

Expand Down
47 changes: 47 additions & 0 deletions pkg/controller/s3/bucket/notificationConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,53 @@ func TestIsNotificationConfigurationUpToDate(t *testing.T) {
isUpToDate: 0,
},
},
"IsUpToDateIgnoreIds": {
args: args{
cr: &v1beta1.NotificationConfiguration{
LambdaFunctionConfigurations: []v1beta1.LambdaFunctionConfiguration{{
Events: generateNotificationEvents(),
Filter: generateNotificationFilter(),
ID: awsclient.String("lambda-id-1"),
LambdaFunctionArn: lambdaArn,
}},
QueueConfigurations: []v1beta1.QueueConfiguration{{
Events: generateNotificationEvents(),
Filter: generateNotificationFilter(),
ID: awsclient.String("queue-id-1"),
QueueArn: queueArn,
}},
TopicConfigurations: []v1beta1.TopicConfiguration{{
Events: generateNotificationEvents(),
Filter: generateNotificationFilter(),
ID: awsclient.String("topic-id-1"),
TopicArn: &topicArn,
}},
},
b: &s3.GetBucketNotificationConfigurationOutput{
LambdaFunctionConfigurations: []s3types.LambdaFunctionConfiguration{{
Events: generateNotificationAWSEvents(),
Filter: generateAWSNotificationFilter(),
Id: awsclient.String("lambda-id-2"),
LambdaFunctionArn: &lambdaArn,
}},
QueueConfigurations: []s3types.QueueConfiguration{{
Events: generateNotificationAWSEvents(),
Filter: generateAWSNotificationFilter(),
Id: awsclient.String("queue-id-2"),
QueueArn: &queueArn,
}},
TopicConfigurations: []s3types.TopicConfiguration{{
Events: generateNotificationAWSEvents(),
Filter: generateAWSNotificationFilter(),
Id: awsclient.String("topic-id-2"),
TopicArn: &topicArn,
}},
},
},
want: want{
isUpToDate: 0,
},
},
"IsUpToDateRulesOutOfOrder": {
args: args{
cr: &v1beta1.NotificationConfiguration{
Expand Down

0 comments on commit 05634a7

Please sign in to comment.