Custom resource definition
Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
This commit is contained in:
parent
cfaf47c8a2
commit
4c060a78cc
1348 changed files with 92364 additions and 55766 deletions
42
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
42
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
|
@ -28,30 +28,15 @@ import (
|
|||
|
||||
// Implements RESTScope interface
|
||||
type restScope struct {
|
||||
name RESTScopeName
|
||||
paramName string
|
||||
argumentName string
|
||||
paramDescription string
|
||||
name RESTScopeName
|
||||
}
|
||||
|
||||
func (r *restScope) Name() RESTScopeName {
|
||||
return r.name
|
||||
}
|
||||
func (r *restScope) ParamName() string {
|
||||
return r.paramName
|
||||
}
|
||||
func (r *restScope) ArgumentName() string {
|
||||
return r.argumentName
|
||||
}
|
||||
func (r *restScope) ParamDescription() string {
|
||||
return r.paramDescription
|
||||
}
|
||||
|
||||
var RESTScopeNamespace = &restScope{
|
||||
name: RESTScopeNameNamespace,
|
||||
paramName: "namespaces",
|
||||
argumentName: "namespace",
|
||||
paramDescription: "object name and auth scope, such as for teams and projects",
|
||||
name: RESTScopeNameNamespace,
|
||||
}
|
||||
|
||||
var RESTScopeRoot = &restScope{
|
||||
|
@ -77,8 +62,6 @@ type DefaultRESTMapper struct {
|
|||
kindToScope map[schema.GroupVersionKind]RESTScope
|
||||
singularToPlural map[schema.GroupVersionResource]schema.GroupVersionResource
|
||||
pluralToSingular map[schema.GroupVersionResource]schema.GroupVersionResource
|
||||
|
||||
interfacesFunc VersionInterfacesFunc
|
||||
}
|
||||
|
||||
func (m *DefaultRESTMapper) String() string {
|
||||
|
@ -87,16 +70,12 @@ func (m *DefaultRESTMapper) String() string {
|
|||
|
||||
var _ RESTMapper = &DefaultRESTMapper{}
|
||||
|
||||
// VersionInterfacesFunc returns the appropriate typer, and metadata accessor for a
|
||||
// given api version, or an error if no such api version exists.
|
||||
type VersionInterfacesFunc func(version schema.GroupVersion) (*VersionInterfaces, error)
|
||||
|
||||
// NewDefaultRESTMapper initializes a mapping between Kind and APIVersion
|
||||
// to a resource name and back based on the objects in a runtime.Scheme
|
||||
// and the Kubernetes API conventions. Takes a group name, a priority list of the versions
|
||||
// to search when an object has no default version (set empty to return an error),
|
||||
// and a function that retrieves the correct metadata for a given version.
|
||||
func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion, f VersionInterfacesFunc) *DefaultRESTMapper {
|
||||
func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion) *DefaultRESTMapper {
|
||||
resourceToKind := make(map[schema.GroupVersionResource]schema.GroupVersionKind)
|
||||
kindToPluralResource := make(map[schema.GroupVersionKind]schema.GroupVersionResource)
|
||||
kindToScope := make(map[schema.GroupVersionKind]RESTScope)
|
||||
|
@ -111,7 +90,6 @@ func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion, f VersionI
|
|||
defaultGroupVersions: defaultGroupVersions,
|
||||
singularToPlural: singularToPlural,
|
||||
pluralToSingular: pluralToSingular,
|
||||
interfacesFunc: f,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,7 +450,7 @@ func (m *DefaultRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
|
|||
return nil, err
|
||||
}
|
||||
if len(mappings) == 0 {
|
||||
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
|
||||
return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
|
||||
}
|
||||
// since we rely on RESTMappings method
|
||||
// take the first match and return to the caller
|
||||
|
@ -510,7 +488,7 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
|
|||
}
|
||||
|
||||
if len(potentialGVK) == 0 {
|
||||
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
|
||||
return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
|
||||
}
|
||||
|
||||
for _, gvk := range potentialGVK {
|
||||
|
@ -526,18 +504,10 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
|
|||
return nil, fmt.Errorf("the provided version %q and kind %q cannot be mapped to a supported scope", gvk.GroupVersion(), gvk.Kind)
|
||||
}
|
||||
|
||||
interfaces, err := m.interfacesFunc(gvk.GroupVersion())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the provided version %q has no relevant versions: %v", gvk.GroupVersion().String(), err)
|
||||
}
|
||||
|
||||
mappings = append(mappings, &RESTMapping{
|
||||
Resource: res.Resource,
|
||||
Resource: res,
|
||||
GroupVersionKind: gvk,
|
||||
Scope: scope,
|
||||
|
||||
ObjectConvertor: interfaces.ObjectConvertor,
|
||||
MetadataAccessor: interfaces.MetadataAccessor,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue