From a3e2a20a23379bf79d9a4b2f393f379cf4af9a4b Mon Sep 17 00:00:00 2001
From: Danny Kulchinsky <61992380+dkulchinsky@users.noreply.github.com>
Date: Tue, 25 Oct 2022 02:34:07 -0400
Subject: [PATCH] fix finalizers mutation with patchesJson6902 (#5132)

* fix finalizers mutation with patchesJson6902

Signed-off-by: Danny Kulchinsky <dkulchinsky@fastly.com>
---
 pkg/engine/mutate/patch/patchesUtils.go      | 3 ++-
 pkg/engine/mutate/patch/patchesUtils_test.go | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/pkg/engine/mutate/patch/patchesUtils.go b/pkg/engine/mutate/patch/patchesUtils.go
index 189412f054..7c7c1c87ff 100644
--- a/pkg/engine/mutate/patch/patchesUtils.go
+++ b/pkg/engine/mutate/patch/patchesUtils.go
@@ -139,7 +139,8 @@ func ignorePatch(path string) bool {
 			!strings.Contains(path, "/metadata/namespace") &&
 			!strings.Contains(path, "/metadata/annotations") &&
 			!strings.Contains(path, "/metadata/labels") &&
-			!strings.Contains(path, "/metadata/ownerReferences") {
+			!strings.Contains(path, "/metadata/ownerReferences") &&
+			!strings.Contains(path, "/metadata/finalizers") {
 			return true
 		}
 	}
diff --git a/pkg/engine/mutate/patch/patchesUtils_test.go b/pkg/engine/mutate/patch/patchesUtils_test.go
index f65e41db4d..759d397c70 100644
--- a/pkg/engine/mutate/patch/patchesUtils_test.go
+++ b/pkg/engine/mutate/patch/patchesUtils_test.go
@@ -169,6 +169,14 @@ func Test_ignorePath(t *testing.T) {
 			path:   "/metadata/labels",
 			ignore: false,
 		},
+		{
+			path:   "/metadata/ownerReferences",
+			ignore: false,
+		},
+		{
+			path:   "/metadata/finalizers",
+			ignore: false,
+		},
 		{
 			path:   "/metadata/creationTimestamp",
 			ignore: true,