diff --git a/cmd/libs/go2idl/client-gen/generators/client-generator.go b/cmd/libs/go2idl/client-gen/generators/client-generator.go index c4fcefe84ce..d29b0f628bc 100644 --- a/cmd/libs/go2idl/client-gen/generators/client-generator.go +++ b/cmd/libs/go2idl/client-gen/generators/client-generator.go @@ -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), } } diff --git a/cmd/libs/go2idl/namer/plural_namer.go b/cmd/libs/go2idl/namer/plural_namer.go index 3fc4cdb06e2..bcd42c8e12c 100644 --- a/cmd/libs/go2idl/namer/plural_namer.go +++ b/cmd/libs/go2idl/namer/plural_namer.go @@ -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 diff --git a/cmd/libs/go2idl/namer/plural_namer_test.go b/cmd/libs/go2idl/namer/plural_namer_test.go index 1201e84e941..3715ff47ac9 100644 --- a/cmd/libs/go2idl/namer/plural_namer_test.go +++ b/cmd/libs/go2idl/namer/plural_namer_test.go @@ -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