conditions/

directory
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0

README

Conditions

Provides:

  • Condition type as specified in the Kubernetes API Conventions
  • ConditionType and generally useful constants for this type (ie. "Available", "Progressing", "Degraded", and "Upgradeable")
  • Functions for setting, removing, finding, and evaluating conditions.

To use, simply add Conditions to your Custom Resource Status struct like:

// ExampleAppStatus defines the observed state of ExampleApp
type ExampleAppStatus struct {
  ...
  // conditions describes the state of the operator's reconciliation functionality.
  // +patchMergeKey=type
  // +patchStrategy=merge
  // +optional
  // Conditions is a list of conditions related to operator reconciliation
  Conditions []conditions.Condition `json:"conditions,omitempty"  patchStrategy:"merge" patchMergeKey:"type"`
}

Then, as appropriate in your Reconcile function, use conditions.SetStatusCondition like:

instance := &examplev1alpha1.ExampleApp{}
err := r.client.Get(context.TODO(), request.NamespacedName, instance)
...handle err

conditions.SetStatusCondition(&instance.Status.Conditions, conditions.Condition{
  Type:   conditions.ConditionAvailable,
  Status: corev1.ConditionFalse,
  Reason: "ReconcileStarted",
  Message: "Reconciling resource"
})

// Update the status
err = r.client.Status().Update(context.TODO(), instance)
...handle err

Directories

Path Synopsis
Package v1 provides version v1 of the types and functions necessary to manage and inspect a slice of conditions.
Package v1 provides version v1 of the types and functions necessary to manage and inspect a slice of conditions.

Jump to

Keyboard shortcuts

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