Skip to content

Commit 73fe383

Browse files
authored
networkAcl update fails if ruleAction field has camelcase Allow/Deny (#169)
Issue [#1966](aws-controllers-k8s/community#1966) Description of changes: RCA and steps to reproduce are mentioned in the issue By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6e97d23 commit 73fe383

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkg/resource/network_acl/hooks.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"context"
1818
"errors"
1919
"strconv"
20+
"strings"
2021

2122
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
2223
ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log"
@@ -396,13 +397,28 @@ func containsEntry(
396397

397398
for _, e := range entryCollection {
398399
delta := compareNetworkACLEntry(e, entry)
399-
400-
if len(delta.Differences) == 0 {
401-
return true
400+
if !delta.DifferentExcept("NetworkACLEntry.RuleAction") {
401+
// Case insensitive comparison for RuleAction
402+
if compareNetworkACLEntryAtRuleAction(e, entry) {
403+
return true
404+
}
402405
}
403406
}
404407
return false
405408
}
409+
410+
func compareNetworkACLEntryAtRuleAction(entry1 *svcapitypes.NetworkACLEntry, entry2 *svcapitypes.NetworkACLEntry) bool {
411+
if entry1.RuleAction == nil && entry2.RuleAction == nil {
412+
return true
413+
}
414+
415+
if entry1.RuleAction == nil || entry2.RuleAction == nil {
416+
return false
417+
}
418+
419+
return strings.EqualFold(*entry1.RuleAction, *entry2.RuleAction)
420+
}
421+
406422
func (rm *resourceManager) createEntry(
407423
ctx context.Context,
408424
r *resource,

0 commit comments

Comments
 (0)