{"action":"opened","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/7491","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/7491/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/7491/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/7491/events","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/issues/7491","id":71771303,"number":7491,"title":"*DefaultRESTMapper.Add() in restmapper.go generates wrong mapping","user":{"login":"caesarxuchao","id":2823529,"avatar_url":"https://avatars.githubusercontent.com/u/2823529?v=3","gravatar_id":"","url":"https://api.github.com/users/caesarxuchao","html_url":"https://github.com/caesarxuchao","followers_url":"https://api.github.com/users/caesarxuchao/followers","following_url":"https://api.github.com/users/caesarxuchao/following{/other_user}","gists_url":"https://api.github.com/users/caesarxuchao/gists{/gist_id}","starred_url":"https://api.github.com/users/caesarxuchao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caesarxuchao/subscriptions","organizations_url":"https://api.github.com/users/caesarxuchao/orgs","repos_url":"https://api.github.com/users/caesarxuchao/repos","events_url":"https://api.github.com/users/caesarxuchao/events{/privacy}","received_events_url":"https://api.github.com/users/caesarxuchao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-29T03:58:51Z","updated_at":"2015-04-29T03:58:51Z","closed_at":null,"body":"@smarterclayton @derekwaynecarr \r\nIMHO, the \"if _, ok := m.mapping[plural]; !ok\" is problematic.\r\n'''\r\n func (m *DefaultRESTMapper) Add(scope RESTScope, kind string, version string, mixedCase bool) {\r\n     plural, singular := kindToResource(kind, mixedCase)\r\n     meta := typeMeta{APIVersion: version, Kind: kind}\r\n     if _, ok := m.mapping[plural]; !ok {\r\n         m.mapping[plural] = meta\r\n         m.mapping[singular] = meta\r\n         if strings.ToLower(plural) != plural {\r\n             m.mapping[strings.ToLower(plural)] = meta\r\n             m.mapping[strings.ToLower(singular)] = meta\r\n         }\r\n     }\r\n     m.reverse[meta] = plural\r\n     m.scopes[meta] = scope\r\n }\r\n'''\r\nThe init() function in latest.go calls this Add() function when looping over different \"version\" and \"kind\". Because of the aforementioned \"if\" condition, most entries in the \"mapping\" will stuck with v1beta1 \"meta\". This causes issue #7260. @nikhiljindal also found a related problem in latest_test.go in #6377.\r\n\r\n@nikhiljindal and I think we should use an array to note down all \"meta\" instead of filtering the \"meta\" using the \"if\" condition, so that users of the DefaultRESTMapper can consult the array and choose the latest API version."}}