mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
address wojtek-t's comment
This commit is contained in:
parent
80a8295bce
commit
a336ab1f3d
@ -33,15 +33,15 @@ import (
|
||||
// NameSystems returns the name system used by the generators in this package.
|
||||
func NameSystems() namer.NameSystems {
|
||||
pluralExceptions := map[string]string{
|
||||
"Endpoints": "endpoints",
|
||||
"ComponentStatus": "componentStatus",
|
||||
"Endpoints": "Endpoints",
|
||||
"ComponentStatus": "ComponentStatus",
|
||||
}
|
||||
return namer.NameSystems{
|
||||
"public": namer.NewPublicNamer(0),
|
||||
"private": namer.NewPrivateNamer(0),
|
||||
"raw": namer.NewRawNamer("", nil),
|
||||
"publicPlural": namer.NewPluralNamer(pluralExceptions, true),
|
||||
"privatePlural": namer.NewPluralNamer(pluralExceptions, false),
|
||||
"publicPlural": namer.NewPublicPluralNamer(pluralExceptions),
|
||||
"privatePlural": namer.NewPrivatePluralNamer(pluralExceptions),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,20 +19,22 @@ package namer
|
||||
import "k8s.io/kubernetes/cmd/libs/go2idl/types"
|
||||
|
||||
type pluralNamer struct {
|
||||
// key is the case-sensitive type name, value is the case-insensitive
|
||||
// intended output.
|
||||
exceptions map[string]string
|
||||
finalize func(string) string
|
||||
}
|
||||
|
||||
// NewPluralNamer returns a namer that returns the plural form of the input
|
||||
// type's name.
|
||||
func NewPluralNamer(exceptions map[string]string, public bool) *pluralNamer {
|
||||
var finalize func(string) string
|
||||
if public {
|
||||
finalize = IC
|
||||
} else {
|
||||
finalize = IL
|
||||
}
|
||||
return &pluralNamer{exceptions, finalize}
|
||||
// NewPublicPluralNamer returns a namer that returns the plural form of the input
|
||||
// type's name, starting with a uppercase letter.
|
||||
func NewPublicPluralNamer(exceptions map[string]string) *pluralNamer {
|
||||
return &pluralNamer{exceptions, IC}
|
||||
}
|
||||
|
||||
// NewPrivatePluralNamer returns a namer that returns the plural form of the input
|
||||
// type's name, starting with a lowercase letter.
|
||||
func NewPrivatePluralNamer(exceptions map[string]string) *pluralNamer {
|
||||
return &pluralNamer{exceptions, IL}
|
||||
}
|
||||
|
||||
// Name returns the plural form of the type's name. If the type's name is found
|
||||
|
@ -27,8 +27,8 @@ func TestPluralNamer(t *testing.T) {
|
||||
// The type name is already in the plural form
|
||||
"Endpoints": "endpoints",
|
||||
}
|
||||
public := NewPluralNamer(exceptions, true)
|
||||
private := NewPluralNamer(exceptions, false)
|
||||
public := NewPublicPluralNamer(exceptions)
|
||||
private := NewPrivatePluralNamer(exceptions)
|
||||
|
||||
cases := []struct {
|
||||
typeName string
|
||||
|
Loading…
Reference in New Issue
Block a user