metadata

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 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"

	ResourceGroupIDLabel        = LabelKroPrefix + "resource-group-id"
	ResourceGroupNameLabel      = LabelKroPrefix + "resource-group-name"
	ResourceGroupNamespaceLabel = LabelKroPrefix + "resource-group-namespace"
	ResourceGroupVersionLabel   = LabelKroPrefix + "resource-group-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       = "ResourceGroup"
	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 GetResourceGroupInstanceGVK

func GetResourceGroupInstanceGVK(apiVersion, kind string) schema.GroupVersionKind

func GetResourceGroupInstanceGVR

func GetResourceGroupInstanceGVR(apiVersion, kind string) schema.GroupVersionResource

func HasInstanceFinalizer

func HasInstanceFinalizer(obj metav1.Object, uid types.UID) bool

HasInstanceFinalizer checks if the object has an instance-specific finalizer.

func HasInstanceFinalizerUnstructured

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

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

func HasResourceGroupFinalizer

func HasResourceGroupFinalizer(obj metav1.Object) bool

HasResourceGroupFinalizer 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 NewInstanceAndResourceGroupSelector

func NewInstanceAndResourceGroupSelector(instance metav1.Object, resourceGroup 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 NewNodeAndInstanceAndResourceGroupSelector

func NewNodeAndInstanceAndResourceGroupSelector(node metav1.Object, instance metav1.Object, resourceGroup metav1.Object) metav1.LabelSelector

func NewResourceGroupOwnerReference

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

stamped on the CRD and RGIs

func NewResourceGroupSelector

func NewResourceGroupSelector(resourceGroup metav1.Object) metav1.LabelSelector

func RemoveInstanceFinalizer

func RemoveInstanceFinalizer(obj metav1.Object, uid types.UID)

RemoveInstanceFinalizer removes an instance-specific finalizer from the object.

func RemoveInstanceFinalizerUnstructured

func RemoveInstanceFinalizerUnstructured(obj *unstructured.Unstructured, uid types.UID) error

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

func RemoveResourceGroupFinalizer

func RemoveResourceGroupFinalizer(obj metav1.Object)

RemoveResourceGroupFinalizer removes the Kro finalizer from the object.

func SetInstanceFinalizer

func SetInstanceFinalizer(obj metav1.Object, uid types.UID)

SetInstanceFinalizer adds an instance-specific finalizer to the object.

func SetInstanceFinalizerUnstructured

func SetInstanceFinalizerUnstructured(obj *unstructured.Unstructured, uid types.UID) 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 SetResourceGroupFinalizer

func SetResourceGroupFinalizer(obj metav1.Object)

SetResourceGroupFinalizer 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 NewResourceGroupLabeler

func NewResourceGroupLabeler(rgMeta metav1.Object) GenericLabeler

NewResourceGroupLabeler returns a new labeler that sets the ResourceGroupLabel and ResourceGroupIDLabel 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