fix outputversion restmapper

This commit is contained in:
deads2k
2015-11-20 16:19:26 -05:00
parent ed95a6d77f
commit 9e9b9f2da3
2 changed files with 18 additions and 16 deletions

View File

@@ -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