handle overlay array mismatch
@@ -27,7 +27,13 @@ func Mutate(policy kubepolicy.Policy, rawResource []byte, gvk metav1.GroupVersio
// Process Overlay
if rule.Mutation.Overlay != nil {
overlayPatches, err := ProcessOverlay(rule, rawResource, gvk)
- if err == nil && len(overlayPatches) > 0 { // if array elements dont match then we skip(nil patch, no error)
+ if err == nil {
+ if len(overlayPatches) == 0{
+ // if array elements dont match then we skip(nil patch, no error)
+ // or if acnohor is defined and doenst match
+ // policy is not applicable
+ continue
+ }
ri.Addf("Rule %s: Overlay succesfully applied.", rule.Name)
allPatches = append(allPatches, overlayPatches...)
} else {
