func init() { groupMeta, err := latest.RegisterGroup("componentconfig") if err != nil { glog.V(4).Infof("%v", err) return } registeredGroupVersions := registered.GroupVersionsForGroup("componentconfig") groupVersion := registeredGroupVersions[0] *groupMeta = latest.GroupMeta{ GroupVersion: groupVersion, Codec: runtime.CodecFor(api.Scheme, groupVersion.String()), } var versions []string worstToBestGroupVersions := []unversioned.GroupVersion{} for i := len(registeredGroupVersions) - 1; i >= 0; i-- { versions = append(versions, registeredGroupVersions[i].Version) worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i]) } groupMeta.Versions = versions groupMeta.GroupVersions = registeredGroupVersions groupMeta.SelfLinker = runtime.SelfLinker(accessor) // the list of kinds that are scoped at the root of the api hierarchy // if a kind is not enumerated here, it is assumed to have a namespace scope rootScoped := sets.NewString() ignoredKinds := sets.NewString() groupMeta.RESTMapper = api.NewDefaultRESTMapper(worstToBestGroupVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) api.RegisterRESTMapper(groupMeta.RESTMapper) groupMeta.InterfacesFor = interfacesFor }
func init() { groupMeta, err := latest.RegisterGroup("") if err != nil { glog.V(4).Infof("%v", err) return } // Use the first API version in the list of registered versions as the latest. registeredGroupVersions := registered.GroupVersionsForGroup("") groupVersion := registeredGroupVersions[0] *groupMeta = latest.GroupMeta{ GroupVersion: groupVersion, Codec: runtime.CodecFor(api.Scheme, groupVersion.String()), } var versions []string worstToBestGroupVersions := []unversioned.GroupVersion{} for i := len(registeredGroupVersions) - 1; i >= 0; i-- { versions = append(versions, registeredGroupVersions[i].Version) worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i]) } groupMeta.Versions = versions groupMeta.GroupVersions = registeredGroupVersions groupMeta.SelfLinker = runtime.SelfLinker(accessor) // the list of kinds that are scoped at the root of the api hierarchy // if a kind is not enumerated here, it is assumed to have a namespace scope rootScoped := sets.NewString( "Node", "Namespace", "PersistentVolume", "ComponentStatus", ) // these kinds should be excluded from the list of resources ignoredKinds := sets.NewString( "ListOptions", "DeleteOptions", "Status", "PodLogOptions", "PodExecOptions", "PodAttachOptions", "PodProxyOptions", "ThirdPartyResource", "ThirdPartyResourceData", "ThirdPartyResourceList") mapper := api.NewDefaultRESTMapper(worstToBestGroupVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) // setup aliases for groups of resources mapper.AddResourceAlias("all", userResources...) groupMeta.RESTMapper = mapper api.RegisterRESTMapper(groupMeta.RESTMapper) groupMeta.InterfacesFor = interfacesFor }
// RegisterGroup registers a group to GroupMetaMap. func (g GroupMetaMap) RegisterGroup(group string) (*GroupMeta, error) { _, found := g[group] if found { return nil, fmt.Errorf("group %v is already registered", g) } if len(registered.GroupVersionsForGroup(group)) == 0 { return nil, fmt.Errorf("No version is registered for group %v", group) } g[group] = &GroupMeta{} return g[group], nil }