Documentation

Overview

    Package controllerutil contains utility functions for working with and implementing Controllers.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func AddFinalizer

    func AddFinalizer(o client.Object, finalizer string)

      AddFinalizer accepts an Object and adds the provided finalizer if not present.

      func ContainsFinalizer

      func ContainsFinalizer(o client.Object, finalizer string) bool

        ContainsFinalizer checks an Object that the provided finalizer is present.

        func RemoveFinalizer

        func RemoveFinalizer(o client.Object, finalizer string)

          RemoveFinalizer accepts an Object and removes the provided finalizer if present.

          func SetControllerReference

          func SetControllerReference(owner, controlled metav1.Object, scheme *runtime.Scheme) error

            SetControllerReference sets owner as a Controller OwnerReference on controlled. This is used for garbage collection of the controlled object and for reconciling the owner object on changes to controlled (with a Watch + EnqueueRequestForOwner). Since only one OwnerReference can be a controller, it returns an error if there is another OwnerReference with Controller flag set.

            func SetOwnerReference

            func SetOwnerReference(owner, object metav1.Object, scheme *runtime.Scheme) error

              SetOwnerReference is a helper method to make sure the given object contains an object reference to the object provided. This allows you to declare that owner has a dependency on the object without specifying it as a controller. If a reference to the same object already exists, it'll be overwritten with the newly provided version.

              Types

              type AlreadyOwnedError

              type AlreadyOwnedError struct {
              	Object metav1.Object
              	Owner  metav1.OwnerReference
              }

                AlreadyOwnedError is an error returned if the object you are trying to assign a controller reference is already owned by another controller Object is the subject and Owner is the reference for the current owner

                func (*AlreadyOwnedError) Error

                func (e *AlreadyOwnedError) Error() string

                type MutateFn

                type MutateFn func() error

                  MutateFn is a function which mutates the existing object into it's desired state.

                  type Object

                  type Object = client.Object

                    Object allows functions to work indistinctly with any resource that implements both Object interfaces.

                    Deprecated: Use client.Object instead.

                    type OperationResult

                    type OperationResult string

                      OperationResult is the action result of a CreateOrUpdate call

                      const (
                      	// OperationResultNone means that the resource has not been changed
                      	OperationResultNone OperationResult = "unchanged"
                      	// OperationResultCreated means that a new resource is created
                      	OperationResultCreated OperationResult = "created"
                      	// OperationResultUpdated means that an existing resource is updated
                      	OperationResultUpdated OperationResult = "updated"
                      	// OperationResultUpdatedStatus means that an existing resource and its status is updated
                      	OperationResultUpdatedStatus OperationResult = "updatedStatus"
                      	// OperationResultUpdatedStatusOnly means that only an existing status is updated
                      	OperationResultUpdatedStatusOnly OperationResult = "updatedStatusOnly"
                      )

                      func CreateOrPatch

                      func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, f MutateFn) (OperationResult, error)

                        CreateOrPatch creates or patches the given object in the Kubernetes cluster. The object's desired state must be reconciled with the before state inside the passed in callback MutateFn.

                        The MutateFn is called regardless of creating or updating an object.

                        It returns the executed operation and an error.

                        func CreateOrUpdate

                        func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, f MutateFn) (OperationResult, error)

                          CreateOrUpdate creates or updates the given object in the Kubernetes cluster. The object's desired state must be reconciled with the existing state inside the passed in callback MutateFn.

                          The MutateFn is called regardless of creating or updating an object.

                          It returns the executed operation and an error.

                          Example

                            This example creates or updates an existing deployment

                            Output: