Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoOperatorCondition indicates that the operator condition CRD is nil ErrNoOperatorCondition = fmt.Errorf("operator Condition CRD is nil") )
Functions ¶
func GetNamespacedName
deprecated
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.
Deprecated: InClusterFactory{}.GetNamespacedName().
Types ¶
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
deprecated
NewCondition returns a new Condition interface using the provided client for the specified conditionType. The condition will internally fetch the namespacedName of the operatorConditionCRD.
Deprecated: Use InClusterFactory{cl}.NewCondition() instead.
type Factory ¶ added in v0.8.0
type Factory interface { NewCondition(apiv2.ConditionType) (Condition, error) GetNamespacedName() (*types.NamespacedName, error) }
Factory define the interface for building Conditions.
type InClusterFactory ¶ added in v0.8.0
InClusterFactory is a conditions factory that can build conditions and get the namespaced name of the operator's condition based on an in-cluster configuration.
func (InClusterFactory) GetNamespacedName ¶ added in v0.8.0
func (f InClusterFactory) 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.
func (InClusterFactory) NewCondition ¶ added in v0.8.0
func (f InClusterFactory) NewCondition(condType apiv2.ConditionType) (Condition, error)
NewCondition creates a new Condition using the provided client and condition type. The condition's name and namespace are determined by the Factory's GetName and GetNamespace functions.
type Option ¶
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 ¶
WithMessage is an Option, which adds the reason to the condition.
func WithReason ¶
WithReason is an Option, which adds the reason to the condition.