mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Add -o name for commands which use printer to output results
Added a new printer which prints 'resource/name' pair of a given object.
This commit is contained in:
@@ -113,7 +113,7 @@ func NewDefaultRESTMapper(group string, versions []string, f VersionInterfacesFu
|
||||
}
|
||||
|
||||
func (m *DefaultRESTMapper) Add(scope RESTScope, kind string, version string, mixedCase bool) {
|
||||
plural, singular := kindToResource(kind, mixedCase)
|
||||
plural, singular := KindToResource(kind, mixedCase)
|
||||
m.plurals[singular] = plural
|
||||
m.singulars[plural] = singular
|
||||
meta := typeMeta{APIVersion: version, Kind: kind}
|
||||
@@ -131,8 +131,8 @@ func (m *DefaultRESTMapper) Add(scope RESTScope, kind string, version string, mi
|
||||
m.scopes[meta] = scope
|
||||
}
|
||||
|
||||
// kindToResource converts Kind to a resource name.
|
||||
func kindToResource(kind string, mixedCase bool) (plural, singular string) {
|
||||
// KindToResource converts Kind to a resource name.
|
||||
func KindToResource(kind string, mixedCase bool) (plural, singular string) {
|
||||
if len(kind) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ func TestKindToResource(t *testing.T) {
|
||||
{Kind: "lowercases", MixedCase: false, Plural: "lowercases", Singular: "lowercases"},
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
plural, singular := kindToResource(testCase.Kind, testCase.MixedCase)
|
||||
plural, singular := KindToResource(testCase.Kind, testCase.MixedCase)
|
||||
if singular != testCase.Singular || plural != testCase.Plural {
|
||||
t.Errorf("%d: unexpected plural and singular: %s %s", i, plural, singular)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user