common

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildResourceReference

func BuildResourceReference(gvk schema.GroupVersionKind, obj metav1.Object) v1alpha1.ResourceReference

BuildResourceReference builds a ResourceReference for the given object.

func ForResourceMapDNSEntry added in v0.34.0

func ForResourceMapDNSEntry(gkv schema.GroupVersionKind) func(context.Context, client.Object) []reconcile.Request

ForResourceMapDNSEntry returns a function that maps a DNSEntry to its owning resource(s).

func GetAnnotatedOwners

func GetAnnotatedOwners(obj metav1.Object) []string

GetAnnotatedOwners returns the list of owner references stored in the annotation `resources.gardener.cloud/owners`.

func GetDNSNamesFromAnnotations added in v0.36.0

func GetDNSNamesFromAnnotations(log logr.Logger, annotations map[string]string) (*utils.UniqueStrings, error)

GetDNSNamesFromAnnotations extracts DNS names from the corresponding annotation.

func GetMergedAnnotation

func GetMergedAnnotation(gvk schema.GroupVersionKind, state state.AnnotationState, obj metav1.Object) map[string]string

GetMergedAnnotation gets the merged annotations for the given object.

func MapDNSAnnotationToSourceRequest added in v0.34.0

func MapDNSAnnotationToSourceRequest(gkv schema.GroupVersionKind) func(context.Context, client.Object) []reconcile.Request

MapDNSAnnotationToSourceRequest returns a function mapping a DNSAnnotation to its referenced source object.

func NewEventFeedbackWrapper added in v0.34.0

func NewEventFeedbackWrapper(
	recorder RecorderWithDeduplication,
	handler handler.EventHandler,
	mapper handler.MapFunc,
	sourceFetcher FetchSourceFunc,
) handler.EventHandler

NewEventFeedbackWrapper creates a new event feedback wrapper that wraps an existing event handler.

func RelevantDNSEntryPredicate added in v0.34.0

func RelevantDNSEntryPredicate(entryOwnerData EntryOwnerData) predicate.Predicate

RelevantDNSEntryPredicate returns the predicate to be considered for reconciliation.

func RelevantSourceObjectPredicate added in v0.34.0

func RelevantSourceObjectPredicate[SourceObject client.Object](
	r *SourceReconciler[SourceObject],
	isRelevant func(r *SourceReconciler[SourceObject], obj SourceObject) bool,
) predicate.Predicate

RelevantSourceObjectPredicate returns the predicate to be considered for reconciliation.

Types

type DNSSpecInput

type DNSSpecInput struct {
	Names                     *utils.UniqueStrings
	TTL                       *int64
	CNameLookupInterval       *int64
	Targets                   *utils.UniqueStrings
	Text                      *utils.UniqueStrings
	RoutingPolicy             *v1alpha1.RoutingPolicy
	IPStack                   string
	ResolveTargetsToAddresses *bool
	Ignore                    string
}

DNSSpecInput specifies names, targets, and policies for DNS records.

func AugmentFromCommonAnnotations added in v0.36.0

func AugmentFromCommonAnnotations(annotations map[string]string, input DNSSpecInput) (*DNSSpecInput, error)

AugmentFromCommonAnnotations augments the given DNSSpecInput with common annotations.

func GetDNSSpecInputForIngress added in v0.34.0

func GetDNSSpecInputForIngress(log logr.Logger, state state.AnnotationState, gvk schema.GroupVersionKind, ingress *networkingv1.Ingress) (*DNSSpecInput, error)

GetDNSSpecInputForIngress gets the DNS spec input for an Ingress resource.

func GetDNSSpecInputForService

func GetDNSSpecInputForService(log logr.Logger, state state.AnnotationState, gvk schema.GroupVersionKind, svc *corev1.Service) (*DNSSpecInput, error)

GetDNSSpecInputForService gets the DNS spec input for a service of type loadbalancer.

type EntryOwnerData

type EntryOwnerData struct {
	Config config.SourceControllerConfig
	GVK    schema.GroupVersionKind
}

EntryOwnerData contains the information about the owner type of DNSEntry.

func (EntryOwnerData) GetOwnerObjectKeys

func (d EntryOwnerData) GetOwnerObjectKeys(obj metav1.Object) []client.ObjectKey

GetOwnerObjectKeys returns the list of owner object keys for the given

func (EntryOwnerData) IsRelevantEntry

func (d EntryOwnerData) IsRelevantEntry(entry *dnsv1alpha1.DNSEntry) bool

IsRelevantEntry checks whether the given DNSEntry has an owner of the given GroupVersionKind. If sameNamespaceAndCluster is true, only the owner references are checked. Otherwise, the annotation `resources.gardener.cloud/owners` is checked.

type FetchSourceFunc added in v0.34.0

type FetchSourceFunc func(ctx context.Context, request reconcile.Request, entry *v1alpha1.DNSEntry) (client.Object, error)

FetchSourceFunc defines a function type that fetches a Kubernetes object (the source) for a given reconcile.Request. It returns the fetched object and an error if the fetch fails.

type OwnerData

type OwnerData struct {
	Object    metav1.Object
	ClusterID string
	GVK       schema.GroupVersionKind
}

OwnerData contains the information about an owner object.

func (OwnerData) AddOwner

func (o OwnerData) AddOwner(obj metav1.Object, clusterID string) bool

AddOwner adds an owner reference to the given object. If the owner is from the same cluster and namespace, a proper owner reference is added. Otherwise, the owner reference is stored in an annotation.

func (OwnerData) AsAnnotationRef

func (o OwnerData) AsAnnotationRef(targetClusterID string) string

AsAnnotationRef returns the owner reference in the format used in the annotation `resources.gardener.cloud/owners`.

func (OwnerData) HasOwner

func (o OwnerData) HasOwner(obj metav1.Object, clusterID string) bool

HasOwner checks whether the given owner is already present in the object's owner references or in the annotation `resources.gardener.cloud/owners`. It returns true if the owner reference or annotation is already present, false otherwise.

func (OwnerData) RemoveOwner

func (o OwnerData) RemoveOwner(obj metav1.Object, clusterID string) bool

RemoveOwner removes the given owner from the object's owner references or from the annotation `resources.gardener.cloud/owners`. It returns true if an owner reference or annotation was removed, false otherwise.

func (OwnerData) String

func (o OwnerData) String() string

type RecorderWithDeduplication added in v0.34.0

type RecorderWithDeduplication interface {
	events.EventRecorder
	// DedupEventf records an event only if the same event message has not been recorded
	// for the given object within the deduplication TTL.
	DedupEventf(client client.Object, eventtype, reason, action, messageFmt string, args ...any)
}

RecorderWithDeduplication is an event recorder with deduplication capabilities.

func NewDedupRecorder added in v0.34.0

func NewDedupRecorder(recorder events.EventRecorder, ttl time.Duration) RecorderWithDeduplication

NewDedupRecorder creates a new RecorderWithDeduplication with the given TTL for deduplication.

type SourceActuator added in v0.34.0

type SourceActuator[SourceObject client.Object] interface {
	// NewSourceObject creates a new instance of the source object.
	NewSourceObject() SourceObject
	// ReconcileSourceObject reconciles the given source object.
	ReconcileSourceObject(context.Context, *SourceReconciler[SourceObject], SourceObject) (reconcile.Result, error)
	// IsRelevantSourceObject checks whether the given source object is relevant for DNS management.
	IsRelevantSourceObject(*SourceReconciler[SourceObject], SourceObject) bool
	// ControllerName returns the name of this controller.
	ControllerName() string
	// FinalizerLocalName returns the local name of the finalizer.
	FinalizerLocalName() string
	// GetGVK returns the GroupVersionKind of the source object.
	GetGVK() schema.GroupVersionKind
	// ShouldSetTargetEntryAnnotation indicates whether the target DNSEntry annotation should be set on the source object.
	ShouldSetTargetEntryAnnotation() bool
}

SourceActuator is the actuator interface for source reconcilers.

type SourceReconciler added in v0.34.0

type SourceReconciler[SourceObject client.Object] struct {
	Log                logr.Logger
	Client             client.Client
	ControlPlaneClient client.Client
	Recorder           RecorderWithDeduplication
	GVK                schema.GroupVersionKind
	Config             config.SourceControllerConfig
	FinalizerName      string
	SourceClass        string
	TargetClass        string
	State              state.AnnotationState
	// contains filtered or unexported fields
}

SourceReconciler is base for source reconcilers.

func NewSourceReconciler added in v0.34.0

func NewSourceReconciler[SourceObject client.Object](actuator SourceActuator[SourceObject]) *SourceReconciler[SourceObject]

NewSourceReconciler creates a new SourceReconciler for given actuator.

func (*SourceReconciler[SourceObject]) AddToManager added in v0.34.0

func (r *SourceReconciler[SourceObject]) AddToManager(
	mgr manager.Manager,
	controlPlaneCluster cluster.Cluster,
	cfg *config.DNSManagerConfiguration,
	builderHook func(*builder.Builder) *builder.Builder,
) error

AddToManager adds Reconciler to the given cluster.

func (*SourceReconciler[SourceObject]) DoDelete added in v0.34.0

func (r *SourceReconciler[SourceObject]) DoDelete(ctx context.Context, obj client.Object) (reconcile.Result, error)

DoDelete performs delete reconciliation for given object.

func (*SourceReconciler[SourceObject]) DoReconcile added in v0.34.0

func (r *SourceReconciler[SourceObject]) DoReconcile(ctx context.Context, obj client.Object, dnsSpecInput *DNSSpecInput) (reconcile.Result, error)

DoReconcile reconciles for given object and dnsSpecInput.

func (*SourceReconciler[SourceObject]) IsOwnedByController added in v0.34.0

func (r *SourceReconciler[SourceObject]) IsOwnedByController(entry *dnsv1alpha1.DNSEntry, owner metav1.Object) bool

IsOwnedByController checks whether the given DNSEntry is owned by the given owner.

func (*SourceReconciler[SourceObject]) Reconcile added in v0.34.0

func (r *SourceReconciler[SourceObject]) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

Reconcile reconciles source objects using the actuator.

Jump to

Keyboard shortcuts

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