From a9a2ba84e688ba47be35158fe45b5d14ec14de7e Mon Sep 17 00:00:00 2001 From: David Eads Date: Mon, 16 Jul 2018 13:38:43 -0400 Subject: [PATCH] fill in normal restmapping info with the legacy guess Kubernetes-commit: 5a757b07887a6f84acfe82e090d3ec757ee51989 --- discovery/restmapper.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/discovery/restmapper.go b/discovery/restmapper.go index df5ab0358..49e6da279 100644 --- a/discovery/restmapper.go +++ b/discovery/restmapper.go @@ -98,18 +98,20 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V scope = meta.RESTScopeRoot } - // this is for legacy resources and servers which don't list singular forms. For those we must still guess. - if len(resource.SingularName) == 0 { - versionMapper.Add(gv.WithKind(resource.Kind), scope) - // TODO this is producing unsafe guesses that don't actually work, but it matches previous behavior - versionMapper.Add(gv.WithKind(resource.Kind+"List"), scope) + // if we have a slash, then this is a subresource and we shouldn't create mappings for those. + if strings.Contains(resource.Name, "/") { continue } plural := gv.WithResource(resource.Name) singular := gv.WithResource(resource.SingularName) - versionMapper.AddSpecific(gv.WithKind(resource.Kind), plural, singular, scope) + // this is for legacy resources and servers which don't list singular forms. For those we must still guess. + if len(resource.SingularName) == 0 { + _, singular = meta.UnsafeGuessKindToResource(gv.WithKind(resource.Kind)) + } + versionMapper.AddSpecific(gv.WithKind(strings.ToLower(resource.Kind)), plural, singular, scope) + versionMapper.AddSpecific(gv.WithKind(resource.Kind), plural, singular, scope) // TODO this is producing unsafe guesses that don't actually work, but it matches previous behavior versionMapper.Add(gv.WithKind(resource.Kind+"List"), scope) }