Documentation
¶
Index ¶
- Constants
- Variables
- func CompareRGDOwnership(existing, desired metav1.ObjectMeta) (kroOwned, nameMatch, idMatch bool)
- func ExtractGVKFromUnstructured(unstructured map[string]interface{}) (schema.GroupVersionKind, error)
- func HasGraphRevisionFinalizer(obj metav1.Object) bool
- 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 RemoveGraphRevisionFinalizer(obj metav1.Object)
- func RemoveInstanceFinalizer(obj client.Object)
- func RemoveResourceGraphDefinitionFinalizer(obj metav1.Object)
- func SetGraphRevisionFinalizer(obj metav1.Object)
- func SetInstanceFinalizer(obj client.Object)
- func SetResourceGraphDefinitionFinalizer(obj metav1.Object)
- type GenericLabeler
- func NewCollectionItemLabeler(nodeID string, index, size int) GenericLabeler
- func NewGraphRevisionHashLabeler(specHash string) GenericLabeler
- func NewInstanceLabeler(instance *unstructured.Unstructured, namespaced bool) GenericLabeler
- func NewKROMetaLabeler() GenericLabeler
- func NewNodeLabeler() GenericLabeler
- func NewResourceGraphDefinitionLabeler(rgMeta metav1.Object) 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" // GraphRevisionHashLabel stores a label-safe representation of the GraphRevision spec hash. GraphRevisionHashLabel = LabelKROPrefix + "graph-revision-hash" )
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 HasGraphRevisionFinalizer ¶ added in v0.2.0
HasGraphRevisionFinalizer checks if the object has the kro finalizer.
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 NewInstanceAndResourceGraphDefinitionSelector ¶
func NewInstanceAndResourceGraphDefinitionSelector(instance metav1.Object, resourceGraphDefinition metav1.Object) metav1.LabelSelector
NewInstanceAndResourceGraphDefinitionSelector returns a selector combining instance and RGD labels. Only matches resources that carry both — typically instances themselves, not child resources (which do not carry RGD labels).
func NewInstanceSelector ¶
func NewInstanceSelector(instance metav1.Object) metav1.LabelSelector
func NewNodeAndInstanceAndResourceGraphDefinitionSelector ¶
func NewNodeAndInstanceAndResourceGraphDefinitionSelector(node metav1.Object, instance metav1.Object, resourceGraphDefinition metav1.Object) metav1.LabelSelector
NewNodeAndInstanceAndResourceGraphDefinitionSelector returns a selector combining node, instance, and RGD labels. Only matches resources that carry all three — child resources do not carry RGD labels, so this selector will not match them. Use NewInstanceSelector for child resource lookups.
func NewResourceGraphDefinitionSelector ¶
func NewResourceGraphDefinitionSelector(resourceGraphDefinition metav1.Object) metav1.LabelSelector
NewResourceGraphDefinitionSelector returns a selector matching resources that carry RGD labels (CRDs and instances). Child resources managed by an instance do NOT carry RGD labels; use NewInstanceSelector to find child resources.
func RemoveGraphRevisionFinalizer ¶ added in v0.2.0
RemoveGraphRevisionFinalizer removes the kro finalizer from the object.
func RemoveInstanceFinalizer ¶
RemoveInstanceFinalizer removes an instance-specific finalizer from an unstructured object.
func RemoveResourceGraphDefinitionFinalizer ¶
RemoveResourceGraphDefinitionFinalizer removes the kro finalizer from the object.
func SetGraphRevisionFinalizer ¶ added in v0.2.0
SetGraphRevisionFinalizer adds the kro finalizer to the object if it's not already present.
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 NewGraphRevisionHashLabeler ¶ added in v0.2.0
func NewGraphRevisionHashLabeler(specHash string) GenericLabeler
NewGraphRevisionHashLabeler returns a new labeler that sets a label-safe representation of the GraphRevision spec hash on a resource.
func NewInstanceLabeler ¶
func NewInstanceLabeler(instance *unstructured.Unstructured, namespaced bool) 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, and KROVersion labels on a resource.
func NewNodeLabeler ¶ added in v0.2.0
func NewNodeLabeler() GenericLabeler
NewNodeLabeler returns a new labeler for child resources Only includes app.kubernetes.io/managed-by label, as other labels come from the parent labeler.
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.