Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add ability to set explicit name for policies #5595

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/core/resources/model/display_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func PluralType(resType string) string {
}

func PluralDisplayName(resType string) string {
return DisplayName(PluralType(resType))
return PluralType(DisplayName(resType))
}
7 changes: 6 additions & 1 deletion tools/policy-gen/generator/pkg/parse/policyconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func newPolicyConfig(pkg, name string, markers map[string]string, hasTo, hasFrom
Name: name,
NameLower: strings.ToLower(name),
SingularDisplayName: core_model.DisplayName(name),
PluralDisplayName: core_model.PluralDisplayName(name),
PluralDisplayName: core_model.PluralType(core_model.DisplayName(name)),
michaelbeaumont marked this conversation as resolved.
Show resolved Hide resolved
AlternativeNames: []string{strings.ToLower(name)},
HasTo: hasTo,
HasFrom: hasFrom,
Expand All @@ -132,6 +132,11 @@ func newPolicyConfig(pkg, name string, markers map[string]string, hasTo, hasFrom
res.SkipGetDefault = v
}

if v, ok := markers["kuma:policy:singular_display_name"]; ok {
res.SingularDisplayName = v
res.PluralDisplayName = core_model.PluralType(v)
}

if v, ok := markers["kuma:policy:plural"]; ok {
res.Plural = v
} else {
Expand Down