mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
fill in normal restmapping info with the legacy guess
This commit is contained in:
parent
72440a10e9
commit
0aa13d7502
@ -99,18 +99,20 @@ func NewDiscoveryRESTMapper(groupResources []*APIGroupResources) meta.RESTMapper
|
|||||||
scope = meta.RESTScopeRoot
|
scope = meta.RESTScopeRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is for legacy resources and servers which don't list singular forms. For those we must still guess.
|
// if we have a slash, then this is a subresource and we shouldn't create mappings for those.
|
||||||
if len(resource.SingularName) == 0 {
|
if strings.Contains(resource.Name, "/") {
|
||||||
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)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
plural := gv.WithResource(resource.Name)
|
plural := gv.WithResource(resource.Name)
|
||||||
singular := gv.WithResource(resource.SingularName)
|
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(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
|
// TODO this is producing unsafe guesses that don't actually work, but it matches previous behavior
|
||||||
versionMapper.Add(gv.WithKind(resource.Kind+"List"), scope)
|
versionMapper.Add(gv.WithKind(resource.Kind+"List"), scope)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user