origin

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package origin provides a mechanism for tracking the provenance of Kubernetes objects that are created by controllers as projections of source objects. It encodes the source object's name, namespace, and UID into labels and annotations on the target object, allowing controllers to determine which source object a target was derived from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Namespace string
	Name      string
	UID       types.UID
}

Data holds the source object's namespace, name, and UID as extracted from origin labels and annotations on a target object.

type Origin

type Origin struct {
	Name       string
	Namespaced bool
}

Origin defines a provenance scheme for tracking which source object a target object was derived from. It stores the source's UID and (optionally) namespace as labels, and the source's name as an annotation on the target object. Set Namespaced to true if the source objects are namespace-scoped.

func (*Origin) Annotations

func (s *Origin) Annotations(sourceObj client.Object) map[string]string

Annotations returns the origin annotations that should be set on a target object for the given source.

func (*Origin) DataOf

func (s *Origin) DataOf(obj client.Object) *Data

DataOf extracts the origin data from obj's labels and annotations. It returns nil if any required field is missing (UID label, name annotation, and namespace label for namespaced origins).

func (*Origin) Labels

func (s *Origin) Labels(sourceObj client.Object) map[string]string

Labels returns the origin labels that should be set on a target object for the given source.

func (*Origin) NameAnnotationKey

func (s *Origin) NameAnnotationKey() string

NameAnnotationKey returns the annotation key used to store the source object's name.

func (*Origin) NamespaceLabelKey

func (s *Origin) NamespaceLabelKey() string

NamespaceLabelKey returns the label key used to store the source object's namespace.

func (*Origin) RemoveOrigin

func (s *Origin) RemoveOrigin(obj client.Object)

RemoveOrigin removes all origin labels and annotations from the given object.

func (*Origin) SetOrigin

func (s *Origin) SetOrigin(sourceObj, obj client.Object)

SetOrigin stamps the target object with origin labels and annotations derived from the source object. Existing labels and annotations on the target are preserved.

func (*Origin) StemsFrom

func (s *Origin) StemsFrom(obj, sourceObj client.Object) bool

StemsFrom reports whether obj was derived from sourceObj by comparing the stored UID.

func (*Origin) StemsFromKey

func (s *Origin) StemsFromKey(obj client.Object, key client.ObjectKey) bool

StemsFromKey reports whether obj was derived from a source object identified by the given namespace/name key.

func (*Origin) UIDLabelKey

func (s *Origin) UIDLabelKey() string

UIDLabelKey returns the label key used to store the source object's UID.

Jump to

Keyboard shortcuts

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