Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
praneetloke committed May 27, 2024
1 parent fb439a0 commit 5fa7b5b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5fa7b5b

Please sign in to comment.