mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
fix outputversion restmapper
This commit is contained in:
@@ -51,21 +51,12 @@ type OutputVersionMapper struct {
|
||||
|
||||
// RESTMapping implements meta.RESTMapper by prepending the output version to the preferred version list.
|
||||
func (m OutputVersionMapper) RESTMapping(kind string, versions ...string) (*meta.RESTMapping, error) {
|
||||
preferred := []string{m.OutputVersion}
|
||||
for _, version := range versions {
|
||||
if len(version) > 0 {
|
||||
preferred = append(preferred, version)
|
||||
}
|
||||
mapping, err := m.RESTMapper.RESTMapping(kind, m.OutputVersion)
|
||||
if err == nil {
|
||||
return mapping, nil
|
||||
}
|
||||
// if the caller wants to use the default version list, try with the preferred version, and on
|
||||
// error, use the default behavior.
|
||||
if len(preferred) == 1 {
|
||||
if m, err := m.RESTMapper.RESTMapping(kind, preferred...); err == nil {
|
||||
return m, nil
|
||||
}
|
||||
preferred = nil
|
||||
}
|
||||
return m.RESTMapper.RESTMapping(kind, preferred...)
|
||||
|
||||
return m.RESTMapper.RESTMapping(kind, versions...)
|
||||
}
|
||||
|
||||
// ShortcutExpander is a RESTMapper that can be used for Kubernetes
|
||||
|
||||
Reference in New Issue
Block a user