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 SetControllerReference

    func SetControllerReference(owner, object v1.Object, scheme *runtime.Scheme) error

      SetControllerReference sets owner as a Controller OwnerReference on owned. This is used for garbage collection of the owned object and for reconciling the owner object on changes to owned (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.

      Types

      type AlreadyOwnedError

      type AlreadyOwnedError struct {
      	Object v1.Object
      	Owner  v1.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(existing runtime.Object) error

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

          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"
            )

            func CreateOrUpdate

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

              CreateOrUpdate creates or updates the given object obj in the Kubernetes cluster. The object's desired state should be reconciled with the existing state using the passed in ReconcileFn. obj must be a struct pointer so that obj can be updated with the content returned by the Server.

              It returns the executed operation and an error.

              Example

                This example creates or updates an existing deployment

                Output: