controller package - github.com/fluxcd/pkg/runtime/controller - Go Packages
Package controller offers embeddable structs for use in your controller and underlying reconcilers, to help with conforming to GitOps Toolkit conventions.
- Constants
- Variables
- func GetDefaultRateLimiter() workqueue.TypedRateLimiter[reconcile.Request]
- func GetInterruptContext(ctx context.Context) context.Context
- func GetRateLimiter(opts RateLimiterOptions) workqueue.TypedRateLimiter[reconcile.Request]
- func GetWatchConfigsPredicate(opts WatchOptions) (predicate.Predicate, error)
- func GetWatchLabelSelector(opts WatchOptions) (*metav1.LabelSelector, error)
- func GetWatchSelector(opts WatchOptions) (labels.Selector, error)
- func NewControllerManagedBy(mgr manager.Manager, r *reconcilerWrapper) *controllerBuilder
- func WrapReconciler(wrapped reconcile.TypedReconciler[ctrl.Request]) *reconcilerWrapper
- type ConnectionOptions
- type Metrics
- func (m Metrics) DeleteCondition(ctx context.Context, obj conditions.Getter, conditionType string)
- func (m Metrics) IsDelete(obj conditions.Getter) bool
- func (m Metrics) RecordCondition(ctx context.Context, obj conditions.Getter, conditionType string)
- func (m Metrics) RecordDuration(ctx context.Context, obj conditions.Getter, startTime time.Time)
- func (m Metrics) RecordReadiness(ctx context.Context, obj conditions.Getter)
- func (m Metrics) RecordReconciling(ctx context.Context, obj conditions.Getter)
- func (m Metrics) RecordStalled(ctx context.Context, obj conditions.Getter)
- func (m Metrics) RecordSuspend(ctx context.Context, obj conditions.Getter, suspend bool)
- type QueueEventSource
- type RateLimiterOptions
- type WatchOptions
const ( EnvRuntimeNamespace = "RUNTIME_NAMESPACE" EnvSourceLocalhost = "SOURCE_CONTROLLER_LOCALHOST" )
const ( FeatureGateAdditiveCELDependencyCheck = "AdditiveCELDependencyCheck" FeatureGateCacheSecretsAndConfigMaps = "CacheSecretsAndConfigMaps" FeatureGateExternalArtifact = "ExternalArtifact" FeatureGateDisableConfigWatchers = "DisableConfigWatchers" FeatureGateDirectSourceFetch = "DirectSourceFetch" )
ErrInsecureHTTPBlocked signals that the use of insecure plain HTTP connections was requested but such behavior is blocked.
GetDefaultRateLimiter returns a new exponential failure workqueue.TypedRateLimiter with the default configuration.
GetInterruptContext returns a context that will be canceled when the object associated with a call to Reconcile() is requeued, or the input context itself if this input context is not associated with a call to Reconcile().
GetRateLimiter returns a new exponential failure workqueue.TypedRateLimiter based on RateLimiterOptions.
GetWatchConfigsPredicate parses the label selector option from WatchOptions and returns the controller-runtime predicate ready for setting up the watch.
GetWatchLabelSelector parses the label selector option from WatchOptions and returns an error if the expression is invalid.
GetWatchSelector parses the label selector option from WatchOptions and returns the label selector. If the WatchOptions contain no selectors, then a match everything is returned.
NewControllerManagedBy returns a wrapped *builder.Builder that facilitates building a controller for a specific object type harvesting the capabilities of the reconciler wrapper.
WrapReconciler wraps a reconcile.TypedReconciler[ctrl.Request] to enhance it with additional functionality.
ConnectionOptions defines the configurable options for outbound connections opened by reconcilers. Consumers are expected to check for compatibility via `CheckEnvironmentCompatibility()` before using its values.
BindFlags will parse the given pflag.FlagSet for the controller and set the ConnectionOptions accordingly.
func (o *ConnectionOptions) CheckEnvironmentCompatibility() error
CheckEnvironmentCompatibility checks if the environment is compatible with the configured connection options.
Metrics is a helper struct that adds the capability for recording GitOps Toolkit standard metrics to a reconciler.
Use it by embedding it in your reconciler struct:
type MyTypeReconciler {
client.Client
// ... etc.
controller.Metrics
}
Following the GitOps Toolkit conventions, API types used in GOTK SHOULD implement conditions.Getter to work with status condition types, and this convention MUST be followed to be able to record metrics using this helper.
Use MustMakeMetrics to create a working Metrics value; you can supply the same value to all reconcilers.
Once initialised, metrics can be recorded by calling one of the available `Record*` methods.
NewMetrics creates a new Metrics with the given metrics.Recorder, and the Metrics.Scheme set to that of the given mgr, along with an optional set of owned finalizers which is used to determine when an object is being deleted.
DeleteCondition deletes the condition metrics of the given conditionType for the given object.
IsDelete returns if the object is deleted by checking for deletion timestamp and owned finalizers in the object.
RecordCondition records the status of the given conditionType for the given obj.
RecordDuration records the duration of a reconcile attempt for the given obj based on the given startTime.
RecordReadiness records the meta.ReadyCondition status for the given obj.
RecordReconciling records the meta.ReconcilingCondition status for the given obj.
RecordStalled records the meta.StalledCondition status for the given obj.
RecordSuspend records the suspension of the given obj based on the given suspend value.
type QueueEventSource struct {
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace"`
UID types.UID `json:"uid"`
ResourceVersion string `json:"resourceVersion"`
}
QueueEventSource holds enough tracking information about the source object that triggered a queue event and implements the error interface.
IsObjectEnqueued returns true if the context belongs to a Reconcile() call and the object associated with that call has been requeued since the reconciliation started. If true, it returns also the watched object that caused the requeue, otherwise it returns nil.
Error returns a string representation of the object represented by QueueEventSource.
Is returns true if the target error is a QueueEventSource object.
RateLimiterOptions defines the configurable options for rate limiters used on reconcilers.
BindFlags will parse the given pflag.FlagSet for the controller and set the RateLimiterOptions accordingly.