diff --git a/controllers/templatesync/template_sync.go b/controllers/templatesync/template_sync.go index 7eb87986..10ff89f9 100644 --- a/controllers/templatesync/template_sync.go +++ b/controllers/templatesync/template_sync.go @@ -1556,9 +1556,6 @@ func hasDupName(pol *policiesv1.Policy) bool { } name := unstructured.GetName() - apiv := unstructured.GetAPIVersion() - kind := unstructured.GetKind() - name = fmt.Sprintf("%s/%s/%s", name, apiv, kind) if _, has := foundNames[name]; has { return true diff --git a/controllers/templatesync/template_sync_test.go b/controllers/templatesync/template_sync_test.go index 9ac5d5cf..44dd9850 100644 --- a/controllers/templatesync/template_sync_test.go +++ b/controllers/templatesync/template_sync_test.go @@ -133,7 +133,7 @@ func TestHasDuplicateNames(t *testing.T) { has := hasDupName(&policy) if has { - t.Fatal("Duplicate names found in templates but not expected") + t.Fatal("Unexpected duplicate policy template names") } // add a gatekeeper constraint template with a duplicate name @@ -161,8 +161,8 @@ func TestHasDuplicateNames(t *testing.T) { policy.Spec.PolicyTemplates = append(policy.Spec.PolicyTemplates, &y) has = hasDupName(&policy) - if has { - t.Fatal("Duplicate names found in templates but not expected") + if !has { + t.Fatal("Duplicate names for templates not detected") } // add a gatekeeper constraint with a duplicate name @@ -190,8 +190,8 @@ func TestHasDuplicateNames(t *testing.T) { policy.Spec.PolicyTemplates = append(policy.Spec.PolicyTemplates, &z) has = hasDupName(&policy) - if has { - t.Fatal("Duplicate names found in templates but not expected") + if !has { + t.Fatal("Duplicate names for templates not detected") } // add a config policy with a duplicate name