Add (stopgap) support for an experimental API prefix.
This commit is contained in:
@@ -63,6 +63,8 @@ var RESTMapper meta.RESTMapper
|
||||
// userResources is a group of resources mostly used by a kubectl user
|
||||
var userResources = []string{"rc", "svc", "pods", "pvc"}
|
||||
|
||||
const importPrefix = "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
|
||||
func init() {
|
||||
// Use the first API version in the list of registered versions as the latest.
|
||||
Version = registered.RegisteredVersions[0]
|
||||
@@ -75,28 +77,14 @@ func init() {
|
||||
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...)
|
||||
rootScoped := util.NewStringSet(
|
||||
"Node",
|
||||
"Minion",
|
||||
"Namespace",
|
||||
"PersistentVolume",
|
||||
)
|
||||
|
||||
// these kinds should be excluded from the list of resources
|
||||
ignoredKinds := util.NewStringSet(
|
||||
@@ -107,20 +95,11 @@ func init() {
|
||||
"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)
|
||||
}
|
||||
}
|
||||
mapper := api.NewDefaultRESTMapper(versions, InterfacesFor, importPrefix, ignoredKinds, rootScoped)
|
||||
// setup aliases for groups of resources
|
||||
mapper.AddResourceAlias("all", userResources...)
|
||||
RESTMapper = mapper
|
||||
api.RegisterRESTMapper(RESTMapper)
|
||||
}
|
||||
|
||||
// InterfacesFor returns the default Codec and ResourceVersioner for a given version
|
||||
|
Reference in New Issue
Block a user