Documentation ¶
Index ¶
- func AddFinalizer[T any, PT ObjectWithDeepCopy[T]](ctx context.Context, log logr.Logger, k8sClient client.Client, obj PT, ...) error
- func Patch[T any, PT ObjectWithDeepCopy[T]](ctx context.Context, k8sClient client.Client, obj PT, modify func()) error
- func PatchResource[T any, PT ObjectWithDeepCopy[T]](ctx context.Context, k8sClient client.Client, obj PT, modify func()) error
- type ObjectReconciler
- type ObjectWithDeepCopy
- type PatchingReconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFinalizer ¶ added in v0.5.0
func Patch ¶
func Patch[T any, PT ObjectWithDeepCopy[T]]( ctx context.Context, k8sClient client.Client, obj PT, modify func(), ) error
Patch updates k8s objects by subsequently calling k8s client `Patch()` and `Status().Patch()` The `modify` lambda is expected to mutate the `obj` but does not take the object as an argument as the object should be visible in the parent scope Example:
var pod *corev1.Pod patchErr = k8s.Patch(ctx, fakeClient, pod, func() { pod.Spec.RestartPolicy = corev1.RestartPolicyOnFailure pod.Status.Message = "hello" })
Note that this function should be used when current user has permissions to patch both object's spec and status, e.g. in controllers context
func PatchResource ¶ added in v0.4.0
func PatchResource[T any, PT ObjectWithDeepCopy[T]]( ctx context.Context, k8sClient client.Client, obj PT, modify func(), ) error
PatchResource updates k8s objects by calling k8s client `Patch`. It does not patch the object status which makes it convenient to use in contexts where the current user is not permitted to patch the status, such as within the api repositories. The `modify` lambda is expected to mutate the `obj` but does not take the object as an argument as the object should be visible in the parent scope Example:
var pod *corev1.Pod patchErr = k8s.PatchResource(ctx, fakeClient, pod, func() { pod.Spec.RestartPolicy = corev1.RestartPolicyOnFailure })
Note that this function should be used when current user has permissions to patch both object's spec and status, e.g. in controllers context
Types ¶
type ObjectReconciler ¶
type ObjectWithDeepCopy ¶
type PatchingReconciler ¶
type PatchingReconciler[T any, PT ObjectWithDeepCopy[T]] struct { // contains filtered or unexported fields }
func NewPatchingReconciler ¶
func NewPatchingReconciler[T any, PT ObjectWithDeepCopy[T]](log logr.Logger, k8sClient client.Client, objectReconciler ObjectReconciler[T, PT]) *PatchingReconciler[T, PT]
func (*PatchingReconciler[T, PT]) SetupWithManager ¶
func (r *PatchingReconciler[T, PT]) SetupWithManager(mgr ctrl.Manager) error