helpers

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndRemoveAnnotation

func CheckAndRemoveAnnotation(
	ctx context.Context,
	c client.Client,
	obj client.Object,
	annotationKey string,
	expectedValue string,
) (bool, error)

CheckAndRemoveAnnotation checks if an annotation exists with a specific value, and removes it if found, updating the object. Returns true if the annotation was found and removed.

func DeleteSecretIfExists

func DeleteSecretIfExists(ctx context.Context, c client.Client, namespace, name string) error

DeleteSecretIfExists deletes a secret, ignoring NotFound errors

func DeleteSecretsIfExist

func DeleteSecretsIfExist(ctx context.Context, c client.Client, namespace string, secretNames []string) error

DeleteSecretsIfExist deletes multiple secrets, ignoring NotFound errors

func EnsureFinalizer

func EnsureFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizerName string) (bool, error)

EnsureFinalizer adds a single finalizer if it doesn't exist. Returns true if an update was performed, false otherwise.

func HasAnnotation

func HasAnnotation(obj client.Object, annotationKey string, expectedValue string) bool

func IsResourceReady added in v0.3.0

func IsResourceReady(conditions []metav1.Condition) bool

IsResourceReady checks if a resource has the Ready condition set to True

func ReconcileFinalizers

func ReconcileFinalizers(ctx context.Context, c client.Client, obj client.Object, updates []FinalizerUpdate) (bool, error)

ReconcileFinalizers manages multiple finalizers in a single update. Returns true if an update was performed, false otherwise.

func RemoveAnnotation

func RemoveAnnotation(ctx context.Context, c client.Client, obj client.Object, annotationKey string) (bool, error)

RemoveAnnotation removes an annotation and updates the object. Returns true if the annotation was found and removed, false if it didn't exist.

func RemoveFinalizers

func RemoveFinalizers(ctx context.Context, c client.Client, obj client.Object, finalizerNames ...string) error

RemoveFinalizers removes multiple finalizers in a single update.

func ResolveOIDCClientReferences added in v0.3.0

func ResolveOIDCClientReferences(
	ctx context.Context,
	c client.Client,
	refs []pocketidv1alpha1.NamespacedOIDCClientReference,
	defaultNamespace string,
) ([]string, error)

ResolveOIDCClientReferences resolves PocketIDOIDCClient references to client IDs

func ResolveSecretKeySelector added in v0.3.0

func ResolveSecretKeySelector(ctx context.Context, c client.Client, apiReader client.Reader, namespace string, ref *corev1.SecretKeySelector) (string, error)

ResolveSecretKeySelector reads the value of a SecretKeySelector from a Kubernetes Secret. Returns an empty string if ref is nil.

func ResolveStringValue

func ResolveStringValue(
	ctx context.Context,
	c client.Client,
	apiReader client.Reader,
	namespace string,
	sv pocketidv1alpha1.StringValue,
	fallbackSecretName string,
	fallbackKey string,
) (string, error)

ResolveStringValue resolves a StringValue to its actual string representation It handles three cases: 1. Direct value from sv.Value 2. Value from a secret reference in sv.ValueFrom (uses apiReader for fresh reads) 3. Fallback to a specified secret name and key (uses apiReader for fresh reads)

The apiReader should be used for user-provided secrets to avoid cache delays. If apiReader is nil, falls back to the cached client.

func ResolveUserGroupReferences

func ResolveUserGroupReferences(
	ctx context.Context,
	c client.Client,
	refs []pocketidv1alpha1.NamespacedUserGroupReference,
	defaultNamespace string,
) ([]string, error)

ResolveUserGroupReferences resolves PocketIDUserGroup references to group IDs

func ResolveUserReferences

func ResolveUserReferences(
	ctx context.Context,
	c client.Client,
	refs []pocketidv1alpha1.NamespacedUserReference,
	defaultNamespace string,
) ([]string, error)

ResolveUserReferences resolves PocketIDUser references to user IDs

Types

type FinalizerUpdate

type FinalizerUpdate struct {
	Name      string
	ShouldAdd bool
}

FinalizerUpdate represents a finalizer that should be added or removed

Jump to

Keyboard shortcuts

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