collection

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByResourceMeta

type ByResourceMeta []v1alpha1.ResourceMeta

ByResourceMeta implements sort.Interface for []v1alpha1.ResourceMeta based on the group and resource fields.

func (ByResourceMeta) Len

func (a ByResourceMeta) Len() int

func (ByResourceMeta) Less

func (a ByResourceMeta) Less(i, j int) bool

func (ByResourceMeta) Swap

func (a ByResourceMeta) Swap(i, j int)

type DuckFilters

type DuckFilters struct {
	// DuckLabel is expected to be in the form:
	//	 `<group>/<names.singular>`
	DuckLabel string
	// DuckVersionFormat is expected to be in the form:
	//   `<names.plural>.<group>`
	// and will be used to assemble `<names.plural>.<group>/<duckVersion>`.
	// This will group duck type defaultVersions based on the given annotation base.
	DuckVersionPrefix string
}

type DuckHunter

type DuckHunter interface {
	// AddCRDs, add a list of CRDs, sorts based on the configuration of the duck hunter.
	AddCRDs(crds []*apiextensionsv1.CustomResourceDefinition)

	// AddCRD, add a single CRD, sorts based on the configuration of the duck hunter.
	AddCRD(crd *apiextensionsv1.CustomResourceDefinition)

	// AddRef is used to insert built-in resource types or types that are not
	// directly in control of the DuckType author but apply to the duck type.
	// Refs are used to override the label and annotation based discovery
	// mechanisms.
	// TODO: if the ref is a CRD, load the CRD and pass that CRD to AddCRD.
	AddRef(duckVersion string, ref v1alpha1.ResourceRef) error

	// Ducks returns the current mapped collection of ducks added to the hunter.
	Ducks() map[string][]v1alpha1.ResourceMeta
}

DuckHunter is used to collect, sort and bucket Kubernetes mappings. This is based on adding CRDs and inspecting labels and annotations, or by adding references directly. The DuckHunter will determine which version of the duck type should be used for each kind of Add function. The current collection of ducks is retrieved by the Ducks() call.

func NewDuckHunter

func NewDuckHunter(mapper ResourceMapper, defaultVersions []v1alpha1.DuckVersion, filters *DuckFilters, clusterRole *rbacv1.ClusterRole) DuckHunter

NewDuckHunter defaultVersions are used to default all the DuckType defaultVersions that apply to unfiltered CRDs.

type ResourceMapper

type ResourceMapper interface {
	// KindExists returns true if the given kind is known for the given
	// groupVersion.
	KindExists(groupVersion, kind string) bool
	// ResourceExists returns true if the given resource is known for the given
	// GroupVersion.
	ResourceExists(groupVersion, resource string) bool
	// KindFor returns the Kind for the given resource in the given
	// GroupVersion.
	KindFor(groupVersion, resource string) (string, error)
	// ResourceFor returns the Kind for the given kind in the given
	// GroupVersion.
	ResourceFor(groupVersion, kind string) (string, error)

	// DeepCopy returns a copy of the ResourceMapper.
	DeepCopy() ResourceMapper
}

ResourceMapper can be used to convert between Resource and Kind or validate a Resource or Kind at a GroupVersion exists on the cluster.

func NewResourceMapper

func NewResourceMapper(apiGroups []*metav1.APIResourceList) ResourceMapper

NewResourceMapper processes a list of APIResourceLists and creates a ResourceMapper that can be used to convert between Resource and Kind or validate a Resource or Kind at a GroupVersion exists on the cluster.

Jump to

Keyboard shortcuts

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