Documentation
¶
Index ¶
- Constants
- Variables
- func MaybeResetRESTMapper(mapper meta.RESTMapper)
- func UnsafeGuessKindToResource(kind schema.GroupVersionKind) (schema.GroupVersionResource, schema.GroupVersionResource)
- type Controller
- type DefaultRESTMapper
- func (m *DefaultRESTMapper) Add(kind schema.GroupVersionKind, scope meta.RESTScope)
- func (m *DefaultRESTMapper) AddSpecific(kind schema.GroupVersionKind, plural, singular schema.GroupVersionResource, ...)
- func (m *DefaultRESTMapper) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
- func (m *DefaultRESTMapper) KindsFor(input schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
- func (m *DefaultRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)
- func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)
- func (m *DefaultRESTMapper) ResourceFor(resource schema.GroupVersionResource) (schema.GroupVersionResource, error)
- func (m *DefaultRESTMapper) ResourceSingularizer(resourceType string) (string, error)
- func (m *DefaultRESTMapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
- func (m *DefaultRESTMapper) String() string
- type DynamicRESTMapper
- type ForCluster
- func (v *ForCluster) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
- func (v *ForCluster) KindsFor(input schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
- func (v *ForCluster) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)
- func (v *ForCluster) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)
- func (v *ForCluster) ResourceFor(resource schema.GroupVersionResource) (schema.GroupVersionResource, error)
- func (v *ForCluster) ResourceSingularizer(resourceType string) (string, error)
- func (v *ForCluster) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
Constants ¶
const (
ControllerName = "kcp-dynamicrestmapper"
)
Variables ¶
var RESTScopeNamespace = &restScope{ name: meta.RESTScopeNameNamespace, }
var RESTScopeRoot = &restScope{ name: meta.RESTScopeNameRoot, }
Functions ¶
func MaybeResetRESTMapper ¶
func MaybeResetRESTMapper(mapper meta.RESTMapper)
MaybeResetRESTMapper calls Reset() on the mapper if it is a ResettableRESTMapper.
func UnsafeGuessKindToResource ¶
func UnsafeGuessKindToResource(kind schema.GroupVersionKind) (schema.GroupVersionResource, schema.GroupVersionResource)
UnsafeGuessKindToResource converts Kind to a resource name. Broken. This method only "sort of" works when used outside of this package. It assumes that Kinds and Resources match and they aren't guaranteed to do so.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController( ctx context.Context, state *DynamicRESTMapper, crdInformer kcpapiextensionsv1informers.CustomResourceDefinitionClusterInformer, apiBindingInformer apisv1alpha2informers.APIBindingClusterInformer, apiExportInformer apisv1alpha2informers.APIExportClusterInformer, apiResourceSchemaInformer apisv1alpha1informers.APIResourceSchemaClusterInformer, globalAPIExportInformer apisv1alpha2informers.APIExportClusterInformer, globalAPIResourceSchemaInformer apisv1alpha1informers.APIResourceSchemaClusterInformer, logicalClusterInformer corev1alpha1informers.LogicalClusterClusterInformer, ) (*Controller, error)
type DefaultRESTMapper ¶
type DefaultRESTMapper struct {
// contains filtered or unexported fields
}
DefaultRESTMapper exposes mappings between the types defined in a runtime.Scheme. It assumes that all types defined the provided scheme can be mapped with the provided MetadataAccessor and Codec interfaces.
The resource name of a Kind is defined as the lowercase, English-plural version of the Kind string. When converting from resource to Kind, the singular version of the resource name is also accepted for convenience.
TODO: Only accept plural for some operations for increased control? (`get pod bar` vs `get pods bar`)
func NewDefaultRESTMapper ¶
func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion) *DefaultRESTMapper
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 (*DefaultRESTMapper) Add ¶
func (m *DefaultRESTMapper) Add(kind schema.GroupVersionKind, scope meta.RESTScope)
func (*DefaultRESTMapper) AddSpecific ¶
func (m *DefaultRESTMapper) AddSpecific(kind schema.GroupVersionKind, plural, singular schema.GroupVersionResource, scope meta.RESTScope)
func (*DefaultRESTMapper) KindFor ¶
func (m *DefaultRESTMapper) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
func (*DefaultRESTMapper) KindsFor ¶
func (m *DefaultRESTMapper) KindsFor(input schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
func (*DefaultRESTMapper) RESTMapping ¶
func (m *DefaultRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)
RESTMapping returns a struct representing the resource path and conversion interfaces a RESTClient should use to operate on the provided group/kind in order of versions. If a version search order is not provided, the search order provided to DefaultRESTMapper will be used to resolve which version should be used to access the named group/kind.
func (*DefaultRESTMapper) RESTMappings ¶
func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)
RESTMappings returns the RESTMappings for the provided group kind. If a version search order is not provided, the search order provided to DefaultRESTMapper will be used.
func (*DefaultRESTMapper) ResourceFor ¶
func (m *DefaultRESTMapper) ResourceFor(resource schema.GroupVersionResource) (schema.GroupVersionResource, error)
func (*DefaultRESTMapper) ResourceSingularizer ¶
func (m *DefaultRESTMapper) ResourceSingularizer(resourceType string) (string, error)
ResourceSingularizer implements RESTMapper It converts a resource name from plural to singular (e.g., from pods to pod)
func (*DefaultRESTMapper) ResourcesFor ¶
func (m *DefaultRESTMapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
func (*DefaultRESTMapper) String ¶
func (m *DefaultRESTMapper) String() string
type DynamicRESTMapper ¶
type DynamicRESTMapper struct {
// contains filtered or unexported fields
}
DynamicRESTMapper is a thread-safe RESTMapper with per-cluster GVK/GVR mappings. The mapping data is fed from its associated Controller (in this package), triggered on CRDs and APIBindings (and their respective APIResourceSchemas). Additionally, mappings for built-in types (pkg/virtual/apiexport/schemas/builtin/builtin.go) are added for each LogicalCluster by default.
func NewDynamicRESTMapper ¶
func NewDynamicRESTMapper(defaultGroupVersions []schema.GroupVersion) *DynamicRESTMapper
func (*DynamicRESTMapper) ForCluster ¶
func (d *DynamicRESTMapper) ForCluster(clusterName logicalcluster.Name) *ForCluster
ForCluster returns a RESTMapper for the specified cluster name. The method never returns nil. If the cluster doesn't exist at the time of calling ForCluster, or if it is deleted while holding the returned RESTMapper instance, all RESTMapper's methods will empty matches and NoResourceMatchError error.
type ForCluster ¶
type ForCluster struct {
// contains filtered or unexported fields
}
Thread-safe wrapper around LogicalCluster->DefaultRESTMapper mapping.
func (*ForCluster) KindFor ¶
func (v *ForCluster) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
KindFor takes a partial resource and returns the single match. Returns an error if there are multiple matches.
func (*ForCluster) KindsFor ¶
func (v *ForCluster) KindsFor(input schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
KindsFor takes a partial resource and returns the list of potential kinds in priority order.
func (*ForCluster) RESTMapping ¶
func (v *ForCluster) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)
RESTMapping identifies a preferred resource mapping for the provided group kind.
func (*ForCluster) RESTMappings ¶
func (v *ForCluster) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)
RESTMappings returns all resource mappings for the provided group kind if no version search is provided. Otherwise identifies a preferred resource mapping for the provided version(s).
func (*ForCluster) ResourceFor ¶
func (v *ForCluster) ResourceFor(resource schema.GroupVersionResource) (schema.GroupVersionResource, error)
ResourceFor takes a partial resource and returns the single match. Returns an error if there are multiple matches.
func (*ForCluster) ResourceSingularizer ¶
func (v *ForCluster) ResourceSingularizer(resourceType string) (string, error)
func (*ForCluster) ResourcesFor ¶
func (v *ForCluster) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
ResourcesFor takes a partial resource and returns the list of potential resource in priority order.