v0.4.1 Latest Latest

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 14




This section is empty.


View Source
var (
	// ErrNoOperatorCondition indicates that the operator condition CRD is nil
	ErrNoOperatorCondition = fmt.Errorf("operator Condition CRD is nil")


func GetNamespacedName

func GetNamespacedName() (*types.NamespacedName, error)

GetNamespacedName returns the NamespacedName of the CR. It returns an error when the name of the CR cannot be found from the environment variable set by OLM. Hence, GetNamespacedName() can provide the NamespacedName when the operator is running on cluster and is being managed by OLM. If running locally, operator writers are encouraged to skip this method or gracefully handle the errors by logging a message.


type Condition

type Condition interface {
	// Get fetches the condition on the operator's
	// OperatorCondition. It returns an error if there are problems getting
	// the OperatorCondition object or if the specific condition type does not
	// exist.
	Get(ctx context.Context) (*metav1.Condition, error)

	// Set sets the specific condition on the operator's
	// OperatorCondition to the provided status. If the condition is not
	// present, it is added to the CR.
	// To set a new condition, the user can call this method and provide optional
	// parameters if required. It returns an error if there are problems getting or
	// updating the OperatorCondition object.
	Set(ctx context.Context, status metav1.ConditionStatus, option ...Option) error

Condition can Get and Set a conditionType in an Operator Condition custom resource associated with the operator.

func NewCondition

func NewCondition(cl client.Client, condType apiv1.ConditionType) (Condition, error)

NewCondition returns a new Condition interface using the provided client for the specified conditionType. The condition will internally fetch the namespacedName of the operatorConditionCRD.

type Option

type Option func(*metav1.Condition)

Option is a function that applies a change to a condition. This can be used to set optional condition fields, like reasons and messages.

func WithMessage

func WithMessage(message string) Option

WithMessage is an Option, which adds the reason to the condition.

func WithReason

func WithReason(reason string) Option

WithReason is an Option, which adds the reason to the condition.

Jump to

Keyboard shortcuts

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