...

Text file src/github.com/openshift/custom-resource-status/conditions/README.md

Documentation: github.com/openshift/custom-resource-status/conditions

     1Conditions
     2==========
     3
     4Provides:
     5
     6* `Condition` type as specified in the [Kubernetes API Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties)
     7* `ConditionType` and generally useful constants for this type (ie. "Available",
     8    "Progressing", "Degraded", and "Upgradeable")
     9* Functions for setting, removing, finding, and evaluating conditions.
    10
    11To use, simply add `Conditions` to your Custom Resource Status struct like:
    12
    13```golang
    14// ExampleAppStatus defines the observed state of ExampleApp
    15type ExampleAppStatus struct {
    16  ...
    17  // conditions describes the state of the operator's reconciliation functionality.
    18  // +patchMergeKey=type
    19  // +patchStrategy=merge
    20  // +optional
    21  // Conditions is a list of conditions related to operator reconciliation
    22  Conditions []conditions.Condition `json:"conditions,omitempty"  patchStrategy:"merge" patchMergeKey:"type"`
    23}
    24```
    25
    26Then, as appropriate in your Reconcile function, use
    27`conditions.SetStatusCondition` like:
    28
    29```golang
    30instance := &examplev1alpha1.ExampleApp{}
    31err := r.client.Get(context.TODO(), request.NamespacedName, instance)
    32...handle err
    33
    34conditions.SetStatusCondition(&instance.Status.Conditions, conditions.Condition{
    35  Type:   conditions.ConditionAvailable,
    36  Status: corev1.ConditionFalse,
    37  Reason: "ReconcileStarted",
    38  Message: "Reconciling resource"
    39})
    40
    41// Update the status
    42err = r.client.Status().Update(context.TODO(), instance)
    43...handle err
    44```

View as plain text