utils

package
v0.0.0-...-9c1f14f Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPrefix = "PLRL"
)
View Source
const OwnerRefAnnotation = "deployments.plural.sh/owner-ref"

Variables

This section is empty.

Functions

func AddFinalizer

func AddFinalizer(obj metav1.Object, finalizers ...string)

AddFinalizer will add the given finalizer to the object. It uses a StringSet to avoid duplicates.

func AddOwnerRefAnnotation

func AddOwnerRefAnnotation(ctx context.Context, client ctrlruntimeclient.Client, owner, object ctrlruntimeclient.Object) error

func GetConfigMapData

func GetConfigMapData(ctx context.Context, client ctrlruntimeclient.Client, namespace string, ref *corev1.ConfigMapKeySelector) (string, error)

func GetEnv

func GetEnv(key, fallback string) string

GetEnv - Lookup the environment variable provided and set to default value if variable isn't set.

func GetFuncMap

func GetFuncMap() template.FuncMap

func GetOwnerRefsAnnotationRequests

func GetOwnerRefsAnnotationRequests(ctx context.Context, c ctrlruntimeclient.Client, object, owner ctrlruntimeclient.Object) []reconcile.Request

func GetPluralEnv

func GetPluralEnv(key, fallback string) string

GetPluralEnv - Lookup the plural environment variable. It has to be prefixed with EnvPrefix. If the variable with the provided key is not set, fallback will be used.

func GetPluralEnvBool

func GetPluralEnvBool(key string, fallback bool) bool

GetPluralEnvBool - Lookup the plural environment variable. It has to be prefixed with EnvPrefix. If the variable with the provided key is not set, fallback will be used.

func HashObject

func HashObject(a any) (string, error)

func HashString

func HashString(s string) string

func MakeTemplate

func MakeTemplate(tmplate string) (*template.Template, error)

func MarkCondition

func MarkCondition(set func(condition metav1.Condition), conditionType v1alpha1.ConditionType, conditionStatus metav1.ConditionStatus, conditionReason v1alpha1.ConditionReason, message string)

func MarkFalse

func MarkFalse(set func(metav1.Condition), conditionType v1alpha1.ConditionType, conditionReason v1alpha1.ConditionReason, message string)

func MarkReadOnly

func MarkReadOnly(resource v1alpha1.ReadOnlyPluralResource)

func MarkTrue

func MarkTrue(set func(metav1.Condition), conditionType v1alpha1.ConditionType, conditionReason v1alpha1.ConditionReason, message string)

func OwnerRefAnnotationEventHandler

func OwnerRefAnnotationEventHandler[T ctrlruntimeclient.Object](c ctrlruntimeclient.Client, owner T) handler.EventHandler

func RemoveFinalizer

func RemoveFinalizer(obj metav1.Object, toRemove ...string)

RemoveFinalizer removes the given finalizers from the object.

func RemoveOwnerRefsByGVK

func RemoveOwnerRefsByGVK(obj ctrlruntimeclient.Object, apiVersion, kind string) bool

RemoveOwnerRefsByGVK removes all owner references matching the specified API version and Kind from the object. This modifies the object in-place without patching. The caller is responsible for persisting the changes. This is useful for cleanup when migrating away from owner references for a specific resource type.

func RenderString

func RenderString(tmplate string, ctx map[string]interface{}) (string, error)

func RenderTemplate

func RenderTemplate(wr io.Writer, tmplate string, ctx map[string]interface{}) error

func SyncCondition

func SyncCondition(set func(condition metav1.Condition), conditionType, status, reason, message *string)

func TryAddControllerRef

func TryAddControllerRef(ctx context.Context, client ctrlruntimeclient.Client, owner ctrlruntimeclient.Object, controlled ctrlruntimeclient.Object, scheme *runtime.Scheme) error

func TryRemoveFinalizer

func TryRemoveFinalizer(ctx context.Context, client ctrlruntimeclient.Client, obj ctrlruntimeclient.Object, finalizers ...string) error

func TryRemoveOwnerRef

func TryRemoveOwnerRef(ctx context.Context, client ctrlruntimeclient.Client, owner ctrlruntimeclient.Object, controlled ctrlruntimeclient.Object, scheme *runtime.Scheme) error

func TryToUpdate

func TryToUpdate(ctx context.Context, client ctrlruntimeclient.Client, object ctrlruntimeclient.Object) error

Types

type ConsoleHelper

type ConsoleHelper struct {
	// contains filtered or unexported fields
}

func NewConsoleHelper

func NewConsoleHelper(ctx context.Context, k8sClient k8sclient.Client) *ConsoleHelper

func (*ConsoleHelper) IDFromRef

func (in *ConsoleHelper) IDFromRef(ref *v1.ObjectReference, resource v1alpha1.PluralResource) (*string, error)

type Patcher

type Patcher[PatchObject ctrlruntimeclient.Object] func(object PatchObject, original PatchObject) (compare any, compareTo any)

Patcher TODO ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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