Merge pull request #7629 from caesarxuchao/new-fix-7260-7491
Change the order the different versions of API are registered
This commit is contained in:
@@ -115,7 +115,9 @@ func NewDefaultRESTMapper(versions []string, f VersionInterfacesFunc) *DefaultRE
|
||||
func (m *DefaultRESTMapper) Add(scope RESTScope, kind string, version string, mixedCase bool) {
|
||||
plural, singular := kindToResource(kind, mixedCase)
|
||||
meta := typeMeta{APIVersion: version, Kind: kind}
|
||||
if _, ok := m.mapping[plural]; !ok {
|
||||
_, ok1 := m.mapping[plural]
|
||||
_, ok2 := m.mapping[strings.ToLower(plural)]
|
||||
if !ok1 && !ok2 {
|
||||
m.mapping[plural] = meta
|
||||
m.mapping[singular] = meta
|
||||
if strings.ToLower(plural) != plural {
|
||||
@@ -155,7 +157,7 @@ func kindToResource(kind string, mixedCase bool) (plural, singular string) {
|
||||
|
||||
// VersionAndKindForResource implements RESTMapper
|
||||
func (m *DefaultRESTMapper) VersionAndKindForResource(resource string) (defaultVersion, kind string, err error) {
|
||||
meta, ok := m.mapping[resource]
|
||||
meta, ok := m.mapping[strings.ToLower(resource)]
|
||||
if !ok {
|
||||
return "", "", fmt.Errorf("no resource %q has been defined", resource)
|
||||
}
|
||||
|
Reference in New Issue
Block a user