dynamicrestmapper

package
v0.28.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControllerName = "kcp-dynamicrestmapper"
)

Variables

View Source
var RESTScopeNamespace = &restScope{
	name: meta.RESTScopeNameNamespace,
}
View Source
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

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 (*Controller) Start

func (c *Controller) Start(ctx context.Context, numThreads int)

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 (*DefaultRESTMapper) AddSpecific

func (m *DefaultRESTMapper) AddSpecific(kind schema.GroupVersionKind, plural, singular schema.GroupVersionResource, scope meta.RESTScope)

func (*DefaultRESTMapper) KindFor

func (*DefaultRESTMapper) KindsFor

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 (*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 (*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

KindFor takes a partial resource and returns the single match. Returns an error if there are multiple matches.

func (*ForCluster) KindsFor

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

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

ResourcesFor takes a partial resource and returns the list of potential resource in priority order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL