Documentation
¶
Index ¶
- Constants
- func GetMaxConcurrentReconcilesDirect[T ControllerConfigurationTypes](ctx context.Context, m *Manager) (int, error)
- func GetRateLimiterDirect[T ControllerConfigurationTypes, R ControllerResultTypes](ctx context.Context, m *Manager) (workqueue.TypedRateLimiter[R], error)
- func GetRequeueDuration[T ControllerConfigurationTypes](ctx context.Context, m *Manager) (time.Duration, error)
- type ControllerConfigurationTypes
- type ControllerResultTypes
- type Manager
- type ManagerConfig
Constants ¶
const (
// ControllerConfigurationName is the name of the global controller configuration resource.
ControllerConfigurationName = "promoter-controller-configuration"
)
Variables ¶
This section is empty.
Functions ¶
func GetMaxConcurrentReconcilesDirect ¶ added in v0.14.0
func GetMaxConcurrentReconcilesDirect[T ControllerConfigurationTypes](ctx context.Context, m *Manager) (int, error)
GetMaxConcurrentReconcilesDirect retrieves the maximum number of concurrent reconciles for a specific controller type using a non-cached read. The type parameter T must satisfy the ControllerConfigurationTypes constraint.
This function bypasses the cache and reads directly from the API server, making it safe to call during SetupWithManager before the cache has started. Use this to configure controller options at build time based on the ControllerConfiguration resource.
Parameters:
- ctx: Context for the request, used for cancellation and deadlines
- m: Manager instance with access to the cluster client
Returns the configured maximum concurrent reconciles, or an error if the configuration cannot be retrieved.
func GetRateLimiterDirect ¶ added in v0.14.0
func GetRateLimiterDirect[T ControllerConfigurationTypes, R ControllerResultTypes](ctx context.Context, m *Manager) (workqueue.TypedRateLimiter[R], error)
GetRateLimiterDirect retrieves a configured rate limiter for a specific controller type using a non-cached read. The type parameter T must satisfy the ControllerConfigurationTypes constraint. The type parameter R is the request type for the rate limiter (e.g., ctrl.Request or mcreconcile.Request).
This function bypasses the cache and reads directly from the API server, making it safe to call during SetupWithManager before the cache has started. Use this to configure controller options at build time based on the ControllerConfiguration resource.
The returned rate limiter can be one of several types (FastSlow, ExponentialFailure, Bucket, or MaxOf) depending on the configuration. See buildRateLimiter for details on supported limiter types.
Parameters:
- ctx: Context for the request, used for cancellation and deadlines
- m: Manager instance with access to the cluster client
Returns a configured TypedRateLimiter for the specified request type, or an error if the configuration cannot be retrieved or the rate limiter cannot be constructed.
func GetRequeueDuration ¶ added in v0.14.0
func GetRequeueDuration[T ControllerConfigurationTypes](ctx context.Context, m *Manager) (time.Duration, error)
GetRequeueDuration retrieves the requeue duration for a specific controller type. The type parameter T must satisfy the ControllerConfigurationTypes constraint.
This function queries the global ControllerConfiguration and extracts the RequeueDuration from the WorkQueue specification for the given controller type.
Important: This method requires the manager's cache to be started.
Parameters:
- ctx: Context for the request, used for cancellation and deadlines
- m: Manager instance with access to the cluster client
Returns the configured requeue duration, or an error if the configuration cannot be retrieved.
Types ¶
type ControllerConfigurationTypes ¶ added in v0.14.0
type ControllerConfigurationTypes interface {
promoterv1alpha1.PromotionStrategyConfiguration |
promoterv1alpha1.ChangeTransferPolicyConfiguration |
promoterv1alpha1.PullRequestConfiguration |
promoterv1alpha1.CommitStatusConfiguration |
promoterv1alpha1.ArgoCDCommitStatusConfiguration |
promoterv1alpha1.TimedCommitStatusConfiguration
}
ControllerConfigurationTypes is a constraint that defines the set of controller configuration types that include a WorkQueue specification. This type constraint is used with generic functions to provide type-safe access to WorkQueue configurations across different controller types.
The following configuration types satisfy this constraint:
- PromotionStrategyConfiguration
- ChangeTransferPolicyConfiguration
- PullRequestConfiguration
- CommitStatusConfiguration
- ArgoCDCommitStatusConfiguration
- TimedCommitStatusConfiguration
type ControllerResultTypes ¶ added in v0.14.0
type ControllerResultTypes interface {
comparable
}
ControllerResultTypes is a constraint that defines the set of result types returned by controller reconciliation methods. This type constraint is used with generic functions to provide type-safe handling of different controller result types.
The following result types satisfy this constraint:
- controllerruntime.Result (used in single-cluster controllers)
- multiclusterruntime.Result (used in multi-cluster controllers)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for managing the global controller configuration for the promoter controller. It provides methods to retrieve controller-specific settings such as requeue durations, rate limiters, and concurrency limits from the cluster's ControllerConfiguration resource.
func NewManager ¶
NewManager creates a new settings Manager instance with the provided client and configuration.
The Manager is used to retrieve and manage controller configuration settings from the cluster's ControllerConfiguration resource. It provides a centralized interface for accessing WorkQueue settings, rate limiters, and other controller-specific configurations.
Parameters:
- client: A Kubernetes client.Client for accessing cluster resources (uses cache)
- apiReader: A client.Reader that reads directly from the API server without cache (for setup-time reads)
- config: ManagerConfig containing the controller's namespace and other static settings
Returns a configured Manager instance ready for use.
func (*Manager) GetArgoCDCommitStatusControllersWatchLocalApplicationsDirect ¶ added in v0.14.0
func (m *Manager) GetArgoCDCommitStatusControllersWatchLocalApplicationsDirect(ctx context.Context) (bool, error)
GetArgoCDCommitStatusControllersWatchLocalApplicationsDirect retrieves the WatchLocalApplications setting from the ArgoCDCommitStatus configuration using a non-cached read.
This function bypasses the cache and reads directly from the API server, making it safe to call during SetupWithManager before the cache has started. Use this to configure controller options at build time based on the ControllerConfiguration resource.
Parameters:
- ctx: Context for the request, used for cancellation and deadlines
- m: Manager instance with access to the cluster client
Returns the configured WatchLocalApplications value, or an error if the configuration cannot be retrieved.
func (*Manager) GetControllerNamespace ¶ added in v0.4.0
GetControllerNamespace returns the namespace where the controller is running.
func (*Manager) GetPullRequestControllersTemplate ¶ added in v0.14.0
func (m *Manager) GetPullRequestControllersTemplate(ctx context.Context) (promoterv1alpha1.PullRequestTemplate, error)
GetPullRequestControllersTemplate retrieves the PullRequest template configuration.
This function fetches the ControllerConfiguration resource from the cluster and extracts the PullRequest template settings. It requires the manager's cache to be started, so do not call this method during SetupWithManager. Instead, call it from within your Reconcile method.
Parameters:
- ctx: Context for the request, used for cancellation and deadlines
Returns the PullRequestTemplate configuration, or an error if it cannot be retrieved.
type ManagerConfig ¶
type ManagerConfig struct {
// ControllerNamespace is the namespace where the promoter controller is running.
// This namespace is used when fetching the ControllerConfiguration resource from the cluster.
ControllerNamespace string
}
ManagerConfig holds the static configuration for the settings Manager.
This configuration is provided at Manager creation time and contains runtime parameters that don't change during the Manager's lifetime. It's used in conjunction with the dynamically-fetched ControllerConfiguration resource to provide complete configuration information for the controller.