Documentation
¶
Index ¶
- Constants
- func GetOwnerRepoInfo(s string) (host, owner, repo string, err error)
- func HashValue(value string) (string, error)
- func Reconcile(ctx context.Context, kubeClient client.Client, ...) (ctrl.Result, error)
- func ReconcileAnnotationValue(object v1.Object) (string, bool)
- type CatalogObject
- type Conditioner
- type LastReconciledAtSetter
- type Propagator
- type ReconcileResult
- type Reconciler
- type RuntimeObject
Constants ¶
const ( // AppliedPropagatorAnnotation stores the list of last applied label keys on the destination object AppliedPropagatorAnnotation = "greenhouse.sap/last-applied-propagator" // PropagateLabelsAnnotation defines which label keys should be propagated from source to destination PropagateLabelsAnnotation = "greenhouse.sap/propagate-labels" )
const ( CreatedReason greenhousemetav1alpha1.ConditionReason = "Created" PendingCreationReason greenhousemetav1alpha1.ConditionReason = "PendingCreation" FailingCreationReason greenhousemetav1alpha1.ConditionReason = "FailingCreation" // ScheduledDeletionReason is used to indicate that the resource is scheduled for deletion ScheduledDeletionReason greenhousemetav1alpha1.ConditionReason = "ScheduledDeletion" PendingDeletionReason greenhousemetav1alpha1.ConditionReason = "PendingDeletion" FailingDeletionReason greenhousemetav1alpha1.ConditionReason = "FailingDeletion" DeletedReason greenhousemetav1alpha1.ConditionReason = "Deleted" CommonCleanupFinalizer = "greenhouse.sap/cleanup" // Success should be returned in case the operator reached its target state Success ReconcileResult = "Success" // Failed should be returned in case the operator wasn't able to reach its target state and without external changes it's unlikely that this will succeed in the next try Failed ReconcileResult = "Failed" // Pending should be returned in case the operator is still trying to reach the target state (Requeue, waiting for remote resource to be cleaned up, etc.) Pending ReconcileResult = "Pending" // SuspendAnnotation is the annotation used to suspend reconciliation of a resource SuspendAnnotation = "greenhouse.sap/suspend" // ReconcileAnnotation is the annotation used to trigger reconciliation of a resource // Any change to the value of this annotation should trigger a reconciliation. ReconcileAnnotation = "greenhouse.sap/reconcile" )
Variables ¶
This section is empty.
Functions ¶
func GetOwnerRepoInfo ¶ added in v0.7.0
GetOwnerRepoInfo - extracts host, owner, repo from git repository URL host is transformed to replace '.' with '-' to be used as source group in Catalog.Status.Inventory
func Reconcile ¶
func Reconcile(ctx context.Context, kubeClient client.Client, namespacedName types.NamespacedName, runtimeObject RuntimeObject, reconciler Reconciler, statusFunc Conditioner) (ctrl.Result, error)
Reconcile - is a generic function that is used to reconcile the state of a resource It standardizes the reconciliation loop and provides a common way to set finalizers, remove finalizers, and update the status of the resource It splits the reconciliation into two phases: EnsureCreated and EnsureDeleted to keep the create / update and delete logic in controllers segregated
Types ¶
type CatalogObject ¶ added in v0.7.0
type Conditioner ¶
type Conditioner func(context.Context, RuntimeObject)
Conditioner is a function that can be used to set the status conditions of the object at a later point in the reconciliation process Provided by the caller of the Reconcile function
type LastReconciledAtSetter ¶ added in v0.7.0
type LastReconciledAtSetter interface {
// SetLastReconciledAtStatus sets the status field for last reconcile annotation
UpdateLastReconciledAtStatus(string)
}
LastReconciledAtSetter is an interface for runtime objects that support setting the lastReconciledAt status
type Propagator ¶ added in v0.5.0
type Propagator struct {
// contains filtered or unexported fields
}
Propagator encapsulates a source and destination object between which label keys are propagated according to configured annotations.
func NewPropagator ¶ added in v0.5.0
func NewPropagator(src, dst client.Object) *Propagator
NewPropagator creates a new Propagator instance for syncing labels between a source and destination Kubernetes object.
func (*Propagator) ApplyLabels ¶ added in v0.5.0
func (p *Propagator) ApplyLabels() client.Object
ApplyLabels - performs idempotent label propagation based on the propagate-labels annotation. It adds or updates only the specified label keys from src to dst, and removes any previously propagated labels that were removed in src or are no longer declared.
type ReconcileResult ¶
type ReconcileResult string
type Reconciler ¶
type Reconciler interface {
EnsureCreated(context.Context, RuntimeObject) (ctrl.Result, ReconcileResult, error)
EnsureDeleted(context.Context, RuntimeObject) (ctrl.Result, ReconcileResult, error)
EnsureSuspended(context.Context, RuntimeObject) (ctrl.Result, error)
}
Reconciler is the interface that wraps the basic EnsureCreated and EnsureDeleted methods that a controller should implement
type RuntimeObject ¶
type RuntimeObject interface {
runtime.Object
v1.Object
// GetConditions returns the status conditions of the object (must be implemented in respective types)
GetConditions() greenhousemetav1alpha1.StatusConditions
// SetCondition sets the status conditions of the object (must be implemented in respective types)
SetCondition(greenhousemetav1alpha1.Condition)
}
RuntimeObject is an interface that generalizes the CR object that is being reconciled