本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/meta.NewDefaultRESTMapper函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDefaultRESTMapper函数的具体用法?Golang NewDefaultRESTMapper怎么用?Golang NewDefaultRESTMapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDefaultRESTMapper函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewDefaultRESTMapper
func NewDefaultRESTMapper(group string, groupVersionStrings []string, interfacesFunc meta.VersionInterfacesFunc,
importPathPrefix string, ignoredKinds, rootScoped sets.String) *meta.DefaultRESTMapper {
mapper := meta.NewDefaultRESTMapper(group, groupVersionStrings, interfacesFunc)
// enumerate all supported versions, get the kinds, and register with the mapper how to address
// our resources.
for _, gvString := range groupVersionStrings {
gv, err := unversioned.ParseGroupVersion(gvString)
// TODO stop panicing when the types are fixed
if err != nil {
panic(err)
}
if gv.Group != group {
panic(fmt.Sprintf("%q does not match the expect %q", gv.Group, group))
}
for kind, oType := range Scheme.KnownTypes(gv.String()) {
// TODO: Remove import path prefix check.
// We check the import path prefix because we currently stuff both "api" and "extensions" objects
// into the same group within Scheme since Scheme has no notion of groups yet.
if !strings.HasPrefix(oType.PkgPath(), importPathPrefix) || ignoredKinds.Has(kind) {
continue
}
scope := meta.RESTScopeNamespace
if rootScoped.Has(kind) {
scope = meta.RESTScopeRoot
}
mapper.Add(scope, kind, gv.String(), false)
}
}
return mapper
}
示例2: newExternalScheme
func newExternalScheme() (*runtime.Scheme, meta.RESTMapper, runtime.Codec) {
scheme := runtime.NewScheme()
scheme.AddKnownTypeWithName(internalGV.WithKind("Type"), &internalType{})
scheme.AddKnownTypeWithName(unlikelyGV.WithKind("Type"), &externalType{})
//This tests that kubectl will not confuse the external scheme with the internal scheme, even when they accidentally have versions of the same name.
scheme.AddKnownTypeWithName(validVersionGV.WithKind("Type"), &ExternalType2{})
codecs := serializer.NewCodecFactory(scheme)
codec := codecs.LegacyCodec(unlikelyGV)
mapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{unlikelyGV, validVersionGV}, func(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) {
return &meta.VersionInterfaces{
ObjectConvertor: scheme,
MetadataAccessor: meta.NewAccessor(),
}, versionErrIfFalse(version == validVersionGV || version == unlikelyGV)
})
for _, gv := range []unversioned.GroupVersion{unlikelyGV, validVersionGV} {
for kind := range scheme.KnownTypes(gv) {
gvk := gv.WithKind(kind)
scope := meta.RESTScopeNamespace
mapper.Add(gvk, scope)
}
}
return scheme, mapper, codec
}
示例3: newExternalScheme
func newExternalScheme() (*runtime.Scheme, meta.RESTMapper, runtime.Codec) {
scheme := runtime.NewScheme()
scheme.AddKnownTypeWithName("", "Type", &internalType{})
scheme.AddKnownTypeWithName("unlikelyversion", "Type", &externalType{})
//This tests that kubectl will not confuse the external scheme with the internal scheme, even when they accidentally have versions of the same name.
scheme.AddKnownTypeWithName(testapi.Version(), "Type", &ExternalType2{})
codec := runtime.CodecFor(scheme, "unlikelyversion")
validVersion := testapi.Version()
mapper := meta.NewDefaultRESTMapper("apitest", []string{"unlikelyversion", validVersion}, func(version string) (*meta.VersionInterfaces, error) {
return &meta.VersionInterfaces{
Codec: runtime.CodecFor(scheme, version),
ObjectConvertor: scheme,
MetadataAccessor: meta.NewAccessor(),
}, versionErrIfFalse(version == validVersion || version == "unlikelyversion")
})
for _, version := range []string{"unlikelyversion", validVersion} {
for kind := range scheme.KnownTypes(version) {
mixedCase := false
scope := meta.RESTScopeNamespace
mapper.Add(scope, kind, version, mixedCase)
}
}
return scheme, mapper, codec
}
示例4: NewDefaultRESTMapper
func NewDefaultRESTMapper(defaultGroupVersions []unversioned.GroupVersion, interfacesFunc meta.VersionInterfacesFunc,
importPathPrefix string, ignoredKinds, rootScoped sets.String) *meta.DefaultRESTMapper {
mapper := meta.NewDefaultRESTMapper(defaultGroupVersions, interfacesFunc)
// enumerate all supported versions, get the kinds, and register with the mapper how to address
// our resources.
for _, gv := range defaultGroupVersions {
for kind, oType := range Scheme.KnownTypes(gv.String()) {
gvk := gv.WithKind(kind)
// TODO: Remove import path prefix check.
// We check the import path prefix because we currently stuff both "api" and "extensions" objects
// into the same group within Scheme since Scheme has no notion of groups yet.
if !strings.HasPrefix(oType.PkgPath(), importPathPrefix) || ignoredKinds.Has(kind) {
continue
}
scope := meta.RESTScopeNamespace
if rootScoped.Has(kind) {
scope = meta.RESTScopeRoot
}
mapper.Add(gvk, scope, false)
}
}
return mapper
}
示例5: defaultAPIGroupVersion
func (c *MasterConfig) defaultAPIGroupVersion() *apiserver.APIGroupVersion {
var restMapper meta.MultiRESTMapper
seenGroups := sets.String{}
for _, gv := range registered.EnabledVersions() {
if seenGroups.Has(gv.Group) {
continue
}
seenGroups.Insert(gv.Group)
groupMeta, err := registered.Group(gv.Group)
if err != nil {
continue
}
restMapper = meta.MultiRESTMapper(append(restMapper, groupMeta.RESTMapper))
}
statusMapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{kubeapiv1.SchemeGroupVersion}, registered.GroupOrDie(kapi.GroupName).InterfacesFor)
statusMapper.Add(kubeapiv1.SchemeGroupVersion.WithKind("Status"), meta.RESTScopeRoot)
restMapper = meta.MultiRESTMapper(append(restMapper, statusMapper))
return &apiserver.APIGroupVersion{
Root: OpenShiftAPIPrefix,
Mapper: restMapper,
Creater: kapi.Scheme,
Typer: kapi.Scheme,
Convertor: kapi.Scheme,
Linker: registered.GroupOrDie("").SelfLinker,
Admit: c.AdmissionControl,
Context: c.getRequestContextMapper(),
SubresourceGroupVersionKind: map[string]unversioned.GroupVersionKind{},
}
}
示例6: init
func init() {
// Use the first API version in the list of registered versions as the latest.
Version = registered.RegisteredVersions[0]
OldestVersion = registered.RegisteredVersions[len(registered.RegisteredVersions)-1]
Codec = runtime.CodecFor(api.Scheme, Version)
// Put the registered versions in Versions in reverse order.
versions := registered.RegisteredVersions
Versions = []string{}
for i := len(versions) - 1; i >= 0; i-- {
Versions = append(Versions, versions[i])
}
mapper := meta.NewDefaultRESTMapper(
versions,
func(version string) (*meta.VersionInterfaces, bool) {
interfaces, err := InterfacesFor(version)
if err != nil {
return nil, false
}
return interfaces, true
},
)
// 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
kindToRootScope := map[string]bool{
"Node": true,
"Minion": true,
"Namespace": true,
"PersistentVolume": true,
}
// setup aliases for groups of resources
mapper.AddResourceAlias("all", userResources...)
// these kinds should be excluded from the list of resources
ignoredKinds := util.NewStringSet(
"ListOptions",
"DeleteOptions",
"Status",
"PodLogOptions",
"PodExecOptions",
"PodProxyOptions")
// enumerate all supported versions, get the kinds, and register with the mapper how to address our resources.
for _, version := range versions {
for kind := range api.Scheme.KnownTypes(version) {
if ignoredKinds.Has(kind) {
continue
}
scope := meta.RESTScopeNamespace
if kindToRootScope[kind] {
scope = meta.RESTScopeRoot
}
mapper.Add(scope, kind, version, false)
}
}
RESTMapper = mapper
}
示例7: NewRESTMapper
func NewRESTMapper() meta.RESTMapper {
mapper := meta.NewDefaultRESTMapper(availableVersions, interfacesFor)
// enumerate all supported versions, get the kinds, and register with the mapper how to address
// our resources.
for _, gv := range availableVersions {
for kind := range configapi.Scheme.KnownTypes(gv) {
mapper.Add(gv.WithKind(kind), meta.RESTScopeRoot)
}
}
return mapper
}
示例8: NewDiscoveryRESTMapper
// NewDiscoveryRESTMapper returns a RESTMapper based on discovery information.
func NewDiscoveryRESTMapper(resources []*unversioned.APIResourceList, versionFunc meta.VersionInterfacesFunc) (*meta.DefaultRESTMapper, error) {
rm := meta.NewDefaultRESTMapper(nil, versionFunc)
for _, resourceList := range resources {
gv, err := schema.ParseGroupVersion(resourceList.GroupVersion)
if err != nil {
return nil, err
}
for _, resource := range resourceList.APIResources {
gvk := gv.WithKind(resource.Kind)
scope := meta.RESTScopeRoot
if resource.Namespaced {
scope = meta.RESTScopeNamespace
}
rm.Add(gvk, scope)
}
}
return rm, nil
}
示例9: NewThirdPartyResourceMapper
func NewThirdPartyResourceMapper(gvs []unversioned.GroupVersion, gvks []unversioned.GroupVersionKind) (meta.RESTMapper, error) {
mapper := meta.NewDefaultRESTMapper(gvs, func(gv unversioned.GroupVersion) (*meta.VersionInterfaces, error) {
for ix := range gvs {
if gvs[ix].Group == gv.Group && gvs[ix].Version == gv.Version {
return &meta.VersionInterfaces{
ObjectConvertor: api.Scheme,
MetadataAccessor: meta.NewAccessor(),
}, nil
}
}
groupVersions := make([]string, 0, len(gvs))
for ix := range gvs {
groupVersions = append(groupVersions, gvs[ix].String())
}
return nil, fmt.Errorf("unsupported storage version: %s (valid: %s)", gv.String(), strings.Join(groupVersions, ", "))
})
for ix := range gvks {
mapper.Add(gvks[ix], meta.RESTScopeNamespace)
}
return mapper, nil
}
示例10: NewDefaultRESTMapper
func NewDefaultRESTMapper(versions []string, interfacesFunc meta.VersionInterfacesFunc, importPathPrefix string,
ignoredKinds, rootScoped util.StringSet) *meta.DefaultRESTMapper {
mapper := meta.NewDefaultRESTMapper(versions, interfacesFunc)
// enumerate all supported versions, get the kinds, and register with the mapper how to address our resources.
for _, version := range versions {
for kind, oType := range Scheme.KnownTypes(version) {
// TODO: Remove import path prefix check.
// We check the import path prefix because we currently stuff both "api" and "experimental" objects
// into the same group within Scheme since Scheme has no notion of groups yet.
if !strings.HasPrefix(oType.PkgPath(), importPathPrefix) || ignoredKinds.Has(kind) {
continue
}
scope := meta.RESTScopeNamespace
if rootScoped.Has(kind) {
scope = meta.RESTScopeRoot
}
mapper.Add(scope, kind, version, false)
}
}
return mapper
}
示例11: Object
func (f *factory) Object() (meta.RESTMapper, runtime.ObjectTyper) {
cfg, err := f.clientConfig.ClientConfig()
checkErrWithPrefix("failed to get client config: ", err)
cmdApiVersion := unversioned.GroupVersion{}
if cfg.GroupVersion != nil {
cmdApiVersion = *cfg.GroupVersion
}
mapper := registered.RESTMapper()
discoveryClient, err := discovery.NewDiscoveryClientForConfig(cfg)
if err == nil {
// register third party resources with the api machinery groups. This probably should be done, but
// its consistent with old code, so we'll start with it.
if err := registerThirdPartyResources(discoveryClient); err != nil {
fmt.Fprintf(os.Stderr, "Unable to register third party resources: %v\n", err)
}
// ThirdPartyResourceData is special. It's not discoverable, but needed for thirdparty resource listing
// TODO eliminate this once we're truly generic.
thirdPartyResourceDataMapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{extensionsv1beta1.SchemeGroupVersion}, registered.InterfacesFor)
thirdPartyResourceDataMapper.Add(extensionsv1beta1.SchemeGroupVersion.WithKind("ThirdPartyResourceData"), meta.RESTScopeNamespace)
mapper = meta.FirstHitRESTMapper{
MultiRESTMapper: meta.MultiRESTMapper{
discovery.NewDeferredDiscoveryRESTMapper(discoveryClient, registered.InterfacesFor),
thirdPartyResourceDataMapper, // needed for TPR printing
registered.RESTMapper(), // hardcoded fall back
},
}
}
// wrap with shortcuts
mapper = NewShortcutExpander(mapper, discoveryClient)
// wrap with output preferences
mapper = kubectl.OutputVersionMapper{RESTMapper: mapper, OutputVersions: []unversioned.GroupVersion{cmdApiVersion}}
return mapper, api.Scheme
}
示例12: init
func init() {
// this keeps us consistent with old code. We can decide if we want to expand our RESTMapper to cover
// api.RESTMapper, which is different than what you'd get from latest.
kubeAPIGroup, err := klatest.Group("")
if err != nil {
panic(err)
}
kubeMapper := kubeAPIGroup.RESTMapper
// list of versions we support on the server, in preferred order
versions := []string{"v1", "v1beta3"}
originMapper := kmeta.NewDefaultRESTMapper(
"",
versions,
func(version string) (*kmeta.VersionInterfaces, error) {
interfaces, err := InterfacesFor(version)
if err != nil {
return nil, err
}
return interfaces, nil
},
)
// 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
kindToRootScope := map[string]bool{
"Status": true,
"Project": true,
"ProjectRequest": true,
"Image": true,
"User": true,
"Identity": true,
"UserIdentityMapping": true,
"Group": true,
"OAuthAccessToken": true,
"OAuthAuthorizeToken": true,
"OAuthClient": true,
"OAuthClientAuthorization": true,
"ClusterRole": true,
"ClusterRoleBinding": true,
"ClusterPolicy": true,
"ClusterPolicyBinding": true,
"ClusterNetwork": true,
"HostSubnet": true,
"NetNamespace": true,
}
// enumerate all supported versions, get the kinds, and register with the mapper how to address our resources
for _, version := range versions {
for kind, t := range api.Scheme.KnownTypes(version) {
if !strings.Contains(t.PkgPath(), "openshift/origin") {
if _, ok := kindToRootScope[kind]; !ok {
continue
}
}
originTypes.Insert(kind)
scope := kmeta.RESTScopeNamespace
_, found := kindToRootScope[kind]
if found || (strings.HasSuffix(kind, "List") && kindToRootScope[strings.TrimSuffix(kind, "List")]) {
scope = kmeta.RESTScopeRoot
}
glog.V(6).Infof("Registering %s %s %s", kind, version, scope.Name())
originMapper.Add(scope, kind, version, false)
}
}
// For Origin we use MultiRESTMapper that handles both Origin and Kubernetes
// objects
RESTMapper = kmeta.MultiRESTMapper{originMapper, kubeMapper}
}
示例13: NewFactory
// NewFactory creates a factory with the default Kubernetes resources defined
// if optionalClientConfig is nil, then flags will be bound to a new clientcmd.ClientConfig.
// if optionalClientConfig is not nil, then this factory will make use of it.
func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
flags.SetNormalizeFunc(utilflag.WarnWordSepNormalizeFunc) // Warn for "_" flags
clientConfig := optionalClientConfig
if optionalClientConfig == nil {
clientConfig = DefaultClientConfig(flags)
}
clients := NewClientCache(clientConfig)
return &Factory{
clients: clients,
flags: flags,
Object: func() (meta.RESTMapper, runtime.ObjectTyper) {
cfg, err := clientConfig.ClientConfig()
checkErrWithPrefix("failed to get client config: ", err)
cmdApiVersion := unversioned.GroupVersion{}
if cfg.GroupVersion != nil {
cmdApiVersion = *cfg.GroupVersion
}
mapper := registered.RESTMapper()
discoveryClient, err := discovery.NewDiscoveryClientForConfig(cfg)
// if we can find the server version and it's current enough to have discovery information, use it. Otherwise,
// fallback to our hardcoded list
if err == nil {
if serverVersion, err := discoveryClient.ServerVersion(); err == nil && useDiscoveryRESTMapper(serverVersion.GitVersion) {
// register third party resources with the api machinery groups. This probably should be done, but
// its consistent with old code, so we'll start with it.
if err := registerThirdPartyResources(discoveryClient); err != nil {
fmt.Fprintf(os.Stderr, "Unable to register third party resources: %v\n", err)
}
// ThirdPartyResourceData is special. It's not discoverable, but needed for thirdparty resource listing
// TODO eliminate this once we're truly generic.
thirdPartyResourceDataMapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{extensionsv1beta1.SchemeGroupVersion}, registered.InterfacesFor)
thirdPartyResourceDataMapper.Add(extensionsv1beta1.SchemeGroupVersion.WithKind("ThirdPartyResourceData"), meta.RESTScopeNamespace)
mapper = meta.FirstHitRESTMapper{
MultiRESTMapper: meta.MultiRESTMapper{
discovery.NewDeferredDiscoveryRESTMapper(discoveryClient, registered.InterfacesFor),
thirdPartyResourceDataMapper,
},
}
}
}
// wrap with shortcuts
mapper = NewShortcutExpander(mapper, discoveryClient)
// wrap with output preferences
mapper = kubectl.OutputVersionMapper{RESTMapper: mapper, OutputVersions: []unversioned.GroupVersion{cmdApiVersion}}
return mapper, api.Scheme
},
UnstructuredObject: func() (meta.RESTMapper, runtime.ObjectTyper, error) {
cfg, err := clients.ClientConfigForVersion(nil)
if err != nil {
return nil, nil, err
}
dc, err := discovery.NewDiscoveryClientForConfig(cfg)
if err != nil {
return nil, nil, err
}
groupResources, err := discovery.GetAPIGroupResources(dc)
if err != nil {
return nil, nil, err
}
// Register unknown APIs as third party for now to make
// validation happy. TODO perhaps make a dynamic schema
// validator to avoid this.
for _, group := range groupResources {
for _, version := range group.Group.Versions {
gv := unversioned.GroupVersion{Group: group.Group.Name, Version: version.Version}
if !registered.IsRegisteredVersion(gv) {
registered.AddThirdPartyAPIGroupVersions(gv)
}
}
}
mapper := discovery.NewRESTMapper(groupResources, meta.InterfacesForUnstructured)
typer := discovery.NewUnstructuredObjectTyper(groupResources)
return NewShortcutExpander(mapper, dc), typer, nil
},
RESTClient: func() (*restclient.RESTClient, error) {
clientConfig, err := clients.ClientConfigForVersion(nil)
if err != nil {
return nil, err
}
return restclient.RESTClientFor(clientConfig)
},
ClientSet: func() (*internalclientset.Clientset, error) {
return clients.ClientSetForVersion(nil)
//.........这里部分代码省略.........
示例14: NewRESTMapper
// NewRESTMapper returns a PriorityRESTMapper based on the discovered
// groups and resources passed in.
func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.VersionInterfacesFunc) meta.RESTMapper {
unionMapper := meta.MultiRESTMapper{}
var groupPriority []string
var resourcePriority []unversioned.GroupVersionResource
var kindPriority []unversioned.GroupVersionKind
for _, group := range groupResources {
groupPriority = append(groupPriority, group.Group.Name)
if len(group.Group.PreferredVersion.Version) != 0 {
preferred := group.Group.PreferredVersion.Version
if _, ok := group.VersionedResources[preferred]; ok {
resourcePriority = append(resourcePriority, unversioned.GroupVersionResource{
Group: group.Group.Name,
Version: group.Group.PreferredVersion.Version,
Resource: meta.AnyResource,
})
kindPriority = append(kindPriority, unversioned.GroupVersionKind{
Group: group.Group.Name,
Version: group.Group.PreferredVersion.Version,
Kind: meta.AnyKind,
})
}
}
for _, discoveryVersion := range group.Group.Versions {
resources, ok := group.VersionedResources[discoveryVersion.Version]
if !ok {
continue
}
gv := unversioned.GroupVersion{Group: group.Group.Name, Version: discoveryVersion.Version}
versionMapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{gv}, versionInterfaces)
for _, resource := range resources {
scope := meta.RESTScopeNamespace
if !resource.Namespaced {
scope = meta.RESTScopeRoot
}
versionMapper.Add(gv.WithKind(resource.Kind), scope)
// TODO only do this if it supports listing
versionMapper.Add(gv.WithKind(resource.Kind+"List"), scope)
}
// TODO why is this type not in discovery (at least for "v1")
versionMapper.Add(gv.WithKind("List"), meta.RESTScopeRoot)
unionMapper = append(unionMapper, versionMapper)
}
}
for _, group := range groupPriority {
resourcePriority = append(resourcePriority, unversioned.GroupVersionResource{
Group: group,
Version: meta.AnyVersion,
Resource: meta.AnyResource,
})
kindPriority = append(kindPriority, unversioned.GroupVersionKind{
Group: group,
Version: meta.AnyVersion,
Kind: meta.AnyKind,
})
}
return meta.PriorityRESTMapper{
Delegate: unionMapper,
ResourcePriority: resourcePriority,
KindPriority: kindPriority,
}
}
示例15: getDelegate
func (d *discoveryRESTMapper) getDelegate() (meta.RESTMapper, error) {
d.initLock.Lock()
defer d.initLock.Unlock()
if d.delegate != nil {
return d.delegate, nil
}
serverGroups, err := d.discoveryClient.ServerGroups()
if err != nil {
return nil, err
}
// always prefer our default group for now. The version should be discovered from discovery, but this will hold us
// for quite some time.
resourcePriority := []unversioned.GroupVersionResource{
{Group: kapi.GroupName, Version: meta.AnyVersion, Resource: meta.AnyResource},
}
kindPriority := []unversioned.GroupVersionKind{
{Group: kapi.GroupName, Version: meta.AnyVersion, Kind: meta.AnyKind},
}
groupPriority := []string{}
unionMapper := meta.MultiRESTMapper{}
for _, group := range serverGroups.Groups {
if len(group.Versions) == 0 {
continue
}
groupPriority = append(groupPriority, group.Name)
if len(group.PreferredVersion.Version) != 0 {
preferredVersion := unversioned.GroupVersion{Group: group.Name, Version: group.PreferredVersion.Version}
if registered.IsEnabledVersion(preferredVersion) {
resourcePriority = append(resourcePriority, preferredVersion.WithResource(meta.AnyResource))
kindPriority = append(kindPriority, preferredVersion.WithKind(meta.AnyKind))
}
}
for _, discoveryVersion := range group.Versions {
version := unversioned.GroupVersion{Group: group.Name, Version: discoveryVersion.Version}
if !registered.IsEnabledVersion(version) {
continue
}
groupMeta, err := registered.Group(group.Name)
if err != nil {
return nil, err
}
resources, err := d.discoveryClient.ServerResourcesForGroupVersion(version.String())
if err != nil {
return nil, err
}
versionMapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{version}, groupMeta.InterfacesFor)
for _, resource := range resources.APIResources {
// TODO properly handle resource versus kind
gvk := version.WithKind(resource.Kind)
scope := meta.RESTScopeNamespace
if !resource.Namespaced {
scope = meta.RESTScopeRoot
}
versionMapper.Add(gvk, scope)
// TODO formalize this by checking to see if they support listing
versionMapper.Add(version.WithKind(resource.Kind+"List"), scope)
}
// we need to add List. Its a special case of something we need that isn't in the discovery doc
if group.Name == kapi.GroupName {
versionMapper.Add(version.WithKind("List"), meta.RESTScopeNamespace)
}
unionMapper = append(unionMapper, versionMapper)
}
}
for _, group := range groupPriority {
resourcePriority = append(resourcePriority, unversioned.GroupVersionResource{Group: group, Version: meta.AnyVersion, Resource: meta.AnyResource})
kindPriority = append(kindPriority, unversioned.GroupVersionKind{Group: group, Version: meta.AnyVersion, Kind: meta.AnyKind})
}
return meta.PriorityRESTMapper{Delegate: unionMapper, ResourcePriority: resourcePriority, KindPriority: kindPriority}, nil
}