Skip to content

Commit

Permalink
Merge pull request #166 from seungsoo-lee/dev
Browse files Browse the repository at this point in the history
Updated duplicated policy handling
  • Loading branch information
seungsoo-lee committed Jun 1, 2021
2 parents de8a85a + 7a27ffe commit 3dd7214
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/networkpolicy/deduplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,13 @@ func updateExistCIDRtoNewFQDN(existingPolicies []types.KnoxNetworkPolicy, newPol

func IsExistingPolicy(existingPolicies []types.KnoxNetworkPolicy, newPolicy types.KnoxNetworkPolicy) bool {
for _, exist := range existingPolicies {
if exist.Metadata["cluster_name"] == newPolicy.Metadata["cluster_name"] &&
exist.Metadata["namespace"] == newPolicy.Metadata["namespace"] &&
cmp.Equal(&exist.Spec, &newPolicy.Spec) {
log.Info().Msgf("Exact matching \n%v\n%v", exist, newPolicy)
if cmp.Equal(&exist.Spec, &newPolicy.Spec) {
return true
} else {
if exist.Metadata["namespace"] == "default" && exist.Spec.Selector.MatchLabels["app"] == "trail-2" &&
newPolicy.Metadata["namespace"] == "default" && newPolicy.Spec.Selector.MatchLabels["app"] == "trail-2" {
log.Info().Msgf("NOT matching \n%v\n%v", exist, newPolicy)
}
}
}

Expand Down

0 comments on commit 3dd7214

Please sign in to comment.