apimachinery: remove misleading NewDefaultRESTMapper
This commit is contained in:
parent
3ab143bc18
commit
87c9f89cb1
@ -31,7 +31,6 @@ go_test(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"default.go",
|
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"errors.go",
|
"errors.go",
|
||||||
"firsthit_restmapper.go",
|
"firsthit_restmapper.go",
|
||||||
@ -54,7 +53,6 @@ go_library(
|
|||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2015 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package meta
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewDefaultRESTMapperFromScheme instantiates a DefaultRESTMapper based on types registered in the given scheme.
|
|
||||||
func NewDefaultRESTMapperFromScheme(defaultGroupVersions []schema.GroupVersion, interfacesFunc VersionInterfacesFunc,
|
|
||||||
ignoredKinds, rootScoped sets.String, scheme *runtime.Scheme) *DefaultRESTMapper {
|
|
||||||
|
|
||||||
mapper := 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 := range scheme.KnownTypes(gv) {
|
|
||||||
gvk := gv.WithKind(kind)
|
|
||||||
if ignoredKinds.Has(kind) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
scope := RESTScopeNamespace
|
|
||||||
if rootScoped.Has(kind) {
|
|
||||||
scope = RESTScopeRoot
|
|
||||||
}
|
|
||||||
mapper.Add(gvk, scope)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mapper
|
|
||||||
}
|
|
@ -172,13 +172,21 @@ func (gmf *GroupMetaFactory) newRESTMapper(scheme *runtime.Scheme, externalVersi
|
|||||||
ignoredKinds = gmf.GroupArgs.IgnoredKinds
|
ignoredKinds = gmf.GroupArgs.IgnoredKinds
|
||||||
}
|
}
|
||||||
|
|
||||||
return meta.NewDefaultRESTMapperFromScheme(
|
mapper := meta.NewDefaultRESTMapper(externalVersions, groupMeta.InterfacesFor)
|
||||||
externalVersions,
|
for _, gv := range externalVersions {
|
||||||
groupMeta.InterfacesFor,
|
for kind := range scheme.KnownTypes(gv) {
|
||||||
ignoredKinds,
|
if ignoredKinds.Has(kind) {
|
||||||
rootScoped,
|
continue
|
||||||
scheme,
|
}
|
||||||
)
|
scope := meta.RESTScopeNamespace
|
||||||
|
if rootScoped.Has(kind) {
|
||||||
|
scope = meta.RESTScopeRoot
|
||||||
|
}
|
||||||
|
mapper.Add(gv.WithKind(kind), scope)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable enables group versions that are allowed, adds methods to the scheme, etc.
|
// Enable enables group versions that are allowed, adds methods to the scheme, etc.
|
||||||
|
@ -167,7 +167,10 @@ func TestInstallAPIGroups(t *testing.T) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mapper := meta.NewDefaultRESTMapperFromScheme([]schema.GroupVersion{gv}, interfacesFor, sets.NewString(), sets.NewString(), scheme)
|
mapper := meta.NewDefaultRESTMapper([]schema.GroupVersion{gv}, interfacesFor)
|
||||||
|
for kind := range scheme.KnownTypes(gv) {
|
||||||
|
mapper.Add(gv.WithKind(kind), meta.RESTScopeNamespace)
|
||||||
|
}
|
||||||
groupMeta := apimachinery.GroupMeta{
|
groupMeta := apimachinery.GroupMeta{
|
||||||
GroupVersion: gv,
|
GroupVersion: gv,
|
||||||
GroupVersions: []schema.GroupVersion{gv},
|
GroupVersions: []schema.GroupVersion{gv},
|
||||||
|
Loading…
Reference in New Issue
Block a user