Skip to content

Commit

Permalink
Undo the template duplication check update
Browse files Browse the repository at this point in the history
The template name duplications could be an issue with users managing
lots of templates and there being a requirement no names can conflict.
To avoid having duplicate names there would need to be additional fields
in the status which I don't want to add unless we have a customer RFE.
This update removes a previous change.

Refs:
 - https://issues.redhat.com/browse/ACM-7265
 - https://issues.redhat.com/browse/ACM-7566

Signed-off-by: Gus Parvin <gparvin@redhat.com>
(cherry picked from commit 3045540)
  • Loading branch information
gparvin authored and magic-mirror-bot[bot] committed Oct 10, 2023
1 parent 2d3c062 commit b0c50a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions controllers/templatesync/template_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions controllers/templatesync/template_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b0c50a1

Please sign in to comment.