metadata

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeIDLabel = LabelKroPrefix + "node-id"

	OwnedLabel           = LabelKroPrefix + "owned"
	KroVersionLabel      = LabelKroPrefix + "kro-version"
	ControllerPodIDLabel = LabelKroPrefix + "controller-pod-id"

	InstanceIDLabel        = LabelKroPrefix + "instance-id"
	InstanceLabel          = LabelKroPrefix + "instance-name"
	InstanceNamespaceLabel = LabelKroPrefix + "instance-namespace"

	ResourceGraphDefinitionIDLabel        = LabelKroPrefix + "resource-graph-definition-id"
	ResourceGraphDefinitionNameLabel      = LabelKroPrefix + "resource-graph-definition-name"
	ResourceGraphDefinitionNamespaceLabel = LabelKroPrefix + "resource-graph-definition-namespace"
	ResourceGraphDefinitionVersionLabel   = LabelKroPrefix + "resource-graph-definition-version"
)
View Source
const (
	KroInstancesGroupSuffix = v1alpha1.KroDomainName
)
View Source
const (
	// LabelKro is the label key used to identify Kro owned resources.
	LabelKroPrefix = v1alpha1.KroDomainName + "/"
)

Variables

View Source
var (
	KRORGOwnerReferenceKind       = "ResourceGraphDefinition"
	KRORGOwnerReferenceAPIVersion = v1alpha1.GroupVersion.String()
)
View Source
var (
	ErrDuplicatedLabels = errors.New("duplicate labels")
)

Functions

func ExtractGVKFromUnstructured

func ExtractGVKFromUnstructured(unstructured map[string]interface{}) (schema.GroupVersionKind, error)

ExtractGVKFromUnstructured extracts the GroupVersionKind from an unstructured object.

func GetResourceGraphDefinitionInstanceGVK

func GetResourceGraphDefinitionInstanceGVK(group, apiVersion, kind string) schema.GroupVersionKind

func GetResourceGraphDefinitionInstanceGVR

func GetResourceGraphDefinitionInstanceGVR(group, apiVersion, kind string) schema.GroupVersionResource

func HasInstanceFinalizerUnstructured

func HasInstanceFinalizerUnstructured(obj *unstructured.Unstructured) (bool, error)

HasInstanceFinalizerUnstructured checks if an unstructured object has an instance-specific finalizer.

func HasResourceGraphDefinitionFinalizer

func HasResourceGraphDefinitionFinalizer(obj metav1.Object) bool

HasResourceGraphDefinitionFinalizer checks if the object has the Kro finalizer.

func IsKroOwned

func IsKroOwned(meta metav1.ObjectMeta) bool

IsKroOwned returns true if the resource is owned by Kro.

func NewInstanceAndResourceGraphDefinitionSelector

func NewInstanceAndResourceGraphDefinitionSelector(instance metav1.Object, resourceGraphDefinition metav1.Object) metav1.LabelSelector

func NewInstanceOwnerReference

func NewInstanceOwnerReference(gvk schema.GroupVersionKind, name string, uid types.UID) metav1.OwnerReference

stamped on the RGI child resources

func NewInstanceSelector

func NewInstanceSelector(instance metav1.Object) metav1.LabelSelector

func NewNodeAndInstanceAndResourceGraphDefinitionSelector

func NewNodeAndInstanceAndResourceGraphDefinitionSelector(node metav1.Object, instance metav1.Object, resourceGraphDefinition metav1.Object) metav1.LabelSelector

func NewResourceGraphDefinitionOwnerReference

func NewResourceGraphDefinitionOwnerReference(name string, uid types.UID) metav1.OwnerReference

stamped on the CRD and RGIs

func NewResourceGraphDefinitionSelector

func NewResourceGraphDefinitionSelector(resourceGraphDefinition metav1.Object) metav1.LabelSelector

func RemoveInstanceFinalizerUnstructured

func RemoveInstanceFinalizerUnstructured(obj *unstructured.Unstructured) error

RemoveInstanceFinalizerUnstructured removes an instance-specific finalizer from an unstructured object.

func RemoveResourceGraphDefinitionFinalizer

func RemoveResourceGraphDefinitionFinalizer(obj metav1.Object)

RemoveResourceGraphDefinitionFinalizer removes the Kro finalizer from the object.

func SetInstanceFinalizerUnstructured

func SetInstanceFinalizerUnstructured(obj *unstructured.Unstructured) error

SetInstanceFinalizerUnstructured adds an instance-specific finalizer to an unstructured object.

func SetKroOwned

func SetKroOwned(meta metav1.ObjectMeta)

SetKroOwned sets the OwnedLabel to true on the resource.

func SetKroUnowned

func SetKroUnowned(meta metav1.ObjectMeta)

SetKroUnowned sets the OwnedLabel to false on the resource.

func SetResourceGraphDefinitionFinalizer

func SetResourceGraphDefinitionFinalizer(obj metav1.Object)

SetResourceGraphDefinitionFinalizer adds the Kro finalizer to the object if it's not already present.

Types

type GenericLabeler

type GenericLabeler map[string]string

GenericLabeler is a map of labels that can be applied to a resource. It implements the Labeler interface.

func NewInstanceLabeler

func NewInstanceLabeler(instanceMeta metav1.Object) GenericLabeler

NewInstanceLabeler returns a new labeler that sets the InstanceLabel and InstanceIDLabel labels on a resource. The InstanceLabel is the namespace and name of the instance that was reconciled to create the resource.

func NewKroMetaLabeler

func NewKroMetaLabeler(
	kroVersion string,
	controllerPodID string,
) GenericLabeler

NewKroMetaLabeler returns a new labeler that sets the OwnedLabel, KroVersion, and ControllerPodID labels on a resource.

func NewResourceGraphDefinitionLabeler

func NewResourceGraphDefinitionLabeler(rgMeta metav1.Object) GenericLabeler

NewResourceGraphDefinitionLabeler returns a new labeler that sets the ResourceGraphDefinitionLabel and ResourceGraphDefinitionIDLabel labels on a resource.

func (GenericLabeler) ApplyLabels

func (gl GenericLabeler) ApplyLabels(meta metav1.Object)

ApplyLabels applies the labels to the resource.

func (GenericLabeler) Copy

func (gl GenericLabeler) Copy() map[string]string

Copy returns a copy of the labels.

func (GenericLabeler) Labels

func (gl GenericLabeler) Labels() map[string]string

Labels returns the labels.

func (GenericLabeler) Merge

func (gl GenericLabeler) Merge(other Labeler) (Labeler, error)

Merge merges the labels from the other labeler into the current labeler. If there are any duplicate keys, an error is returned.

type Labeler

type Labeler interface {
	Labels() map[string]string
	ApplyLabels(metav1.Object)
	Merge(Labeler) (Labeler, error)
}

Labeler is an interface that defines a set of labels that can be applied to a resource.

Jump to

Keyboard shortcuts

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