Skip to content

Commit

Permalink
fix: preserve original case for values when building generic status r…
Browse files Browse the repository at this point in the history
…uleset

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Dec 18, 2023
1 parent 855ef9d commit 869b5fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/tracker/generic/resource_state_json_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package generic
import (
"fmt"

"github.com/samber/lo"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -152,7 +153,15 @@ func casify(in ...string) []string {

casers := []cases.Caser{cases.Lower(language.Und), cases.Title(language.Und)}
for _, value := range in {
result = append(result, value)

for _, caser := range casers {
cased := caser.String(value)

if lo.Contains(result, cased) {
continue
}

result = append(result, caser.String(value))
}
}
Expand Down

0 comments on commit 869b5fe

Please sign in to comment.