Documentation
¶
Index ¶
- Constants
- Variables
- func CompareRGDOwnership(existing, desired metav1.ObjectMeta) (kroOwned, nameMatch, idMatch bool)
- func ExtractGVKFromUnstructured(unstructured map[string]interface{}) (schema.GroupVersionKind, error)
- func HasInstanceFinalizer(obj client.Object) bool
- func HasResourceGraphDefinitionFinalizer(obj metav1.Object) bool
- func IsKROOwned(meta metav1.Object) bool
- func NewInstanceAndResourceGraphDefinitionSelector(instance metav1.Object, resourceGraphDefinition metav1.Object) metav1.LabelSelector
- func NewInstanceSelector(instance metav1.Object) metav1.LabelSelector
- func NewNodeAndInstanceAndResourceGraphDefinitionSelector(node metav1.Object, instance metav1.Object, ...) metav1.LabelSelector
- func NewResourceGraphDefinitionSelector(resourceGraphDefinition metav1.Object) metav1.LabelSelector
- func RemoveInstanceFinalizer(obj client.Object)
- func RemoveResourceGraphDefinitionFinalizer(obj metav1.Object)
- func SetInstanceFinalizer(obj client.Object)
- func SetResourceGraphDefinitionFinalizer(obj metav1.Object)
- type GenericLabeler
- type Labeler
Constants ¶
const ( NodeIDLabel = LabelKROPrefix + "node-id" // Collection labels for tracking collection membership and position. // These enable querying collection resources and understanding their position. CollectionIndexLabel = LabelKROPrefix + "collection-index" CollectionSizeLabel = LabelKROPrefix + "collection-size" OwnedLabel = LabelKROPrefix + "owned" KROVersionLabel = LabelKROPrefix + "kro-version" ManagedByLabelKey = "app.kubernetes.io/managed-by" ManagedByKROValue = "kro" InstanceIDLabel = LabelKROPrefix + "instance-id" InstanceLabel = LabelKROPrefix + "instance-name" InstanceNamespaceLabel = LabelKROPrefix + "instance-namespace" InstanceGroupLabel = LabelKROPrefix + "instance-group" InstanceVersionLabel = LabelKROPrefix + "instance-version" InstanceKindLabel = LabelKROPrefix + "instance-kind" ResourceGraphDefinitionIDLabel = LabelKROPrefix + "resource-graph-definition-id" ResourceGraphDefinitionNameLabel = LabelKROPrefix + "resource-graph-definition-name" ResourceGraphDefinitionNamespaceLabel = LabelKROPrefix + "resource-graph-definition-namespace" ResourceGraphDefinitionVersionLabel = LabelKROPrefix + "resource-graph-definition-version" )
const (
KROInstancesGroupSuffix = v1beta1.KRODomainName
)
const ( // LabelKROPrefix is the label key prefix used to identify KRO owned resources. LabelKROPrefix = v1beta1.KRODomainName + "/" )
Variables ¶
var (
ErrDuplicatedLabels = errors.New("duplicate labels")
)
Functions ¶
func CompareRGDOwnership ¶
func CompareRGDOwnership(existing, desired metav1.ObjectMeta) (kroOwned, nameMatch, idMatch bool)
CompareRGDOwnership compares RGD ownership labels between two resources. Returns three booleans:
- kroOwned: whether the existing resource is owned by KRO
- nameMatch: whether both resources have the same RGD name
- idMatch: whether both resources have the same RGD ID
This allows callers to distinguish between different ownership scenarios:
- kroOwned=true, nameMatch=true, idMatch=true: same RGD, normal update
- kroOwned=true, nameMatch=true, idMatch=false: same RGD name, different ID (adoption)
- kroOwned=true, nameMatch=false: different RGD (conflict)
- kroOwned=false: not owned by KRO (conflict)
func ExtractGVKFromUnstructured ¶
func ExtractGVKFromUnstructured(unstructured map[string]interface{}) (schema.GroupVersionKind, error)
ExtractGVKFromUnstructured extracts the GroupVersionKind from an unstructured object. It performs early validation to fail fast and avoid unnecessary API calls: - apiVersion: parsed with schema.ParseGroupVersion for proper validation - kind: validated as DNS-1035 label after lowercasing
func HasInstanceFinalizer ¶
HasInstanceFinalizer checks if an unstructured object has an instance-specific finalizer.
func HasResourceGraphDefinitionFinalizer ¶
HasResourceGraphDefinitionFinalizer checks if the object has the kro finalizer.
func IsKROOwned ¶
IsKROOwned returns true if the resource is owned by KRO.
func NewInstanceSelector ¶
func NewInstanceSelector(instance metav1.Object) metav1.LabelSelector
func NewResourceGraphDefinitionSelector ¶
func NewResourceGraphDefinitionSelector(resourceGraphDefinition metav1.Object) metav1.LabelSelector
func RemoveInstanceFinalizer ¶
RemoveInstanceFinalizer removes an instance-specific finalizer from an unstructured object.
func RemoveResourceGraphDefinitionFinalizer ¶
RemoveResourceGraphDefinitionFinalizer removes the kro finalizer from the object.
func SetInstanceFinalizer ¶
SetInstanceFinalizer adds an instance-specific finalizer to an unstructured object.
func SetResourceGraphDefinitionFinalizer ¶
SetResourceGraphDefinitionFinalizer adds the kro finalizer to the object if it's not already present.
Types ¶
type GenericLabeler ¶
GenericLabeler is a map of labels that can be applied to a resource. It implements the Labeler interface.
func NewCollectionItemLabeler ¶
func NewCollectionItemLabeler(nodeID string, index, size int) GenericLabeler
NewCollectionItemLabeler returns a new labeler that sets collection-specific labels on a resource that is part of a collection (forEach expansion). - node-id: the resource ID from the RGD (e.g "workerPods") - collection-index: the position in the collection (e.g "0", "1", "2") - collection-size: the total number of items in the collection (e.g "3")
func NewInstanceLabeler ¶
func NewInstanceLabeler(instance *unstructured.Unstructured) 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. It also includes the instance's GVK to allow child resource handlers to filter events by parent instance type.
func NewKROMetaLabeler ¶
func NewKROMetaLabeler() GenericLabeler
NewKROMetaLabeler returns a new labeler that sets the OwnedLabel, KROVersion, and ManagedBy 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.