From 5fa7b5b7e1014d233ea9235d2437138cac660bc7 Mon Sep 17 00:00:00 2001 From: Praneet Loke <1466314+praneetloke@users.noreply.github.com> Date: Sun, 26 May 2024 17:39:11 -0700 Subject: [PATCH] update --- pkg/naming.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/naming.go b/pkg/naming.go index 58b5114..7fea334 100644 --- a/pkg/naming.go +++ b/pkg/naming.go @@ -82,12 +82,20 @@ func addNameOverride(key, value string, m map[string]string) { m[key] = value } +// getSingularNameForResource returns a singular version of a resource name, +// as long as the name doesn't have one of the valid plural names as its +// suffix. func getSingularNameForResource(resourceName string, allowedPluralNames []string) string { + allowPluralName := false for _, n := range allowedPluralNames { - if !strings.HasSuffix(resourceName, n) { - return strings.TrimSuffix(resourceName, "s") + if strings.HasSuffix(resourceName, n) { + allowPluralName = true } } + if !allowPluralName { + return strings.TrimSuffix(resourceName, "s") + } + return resourceName }