operatorconfig

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager[T any] struct {
	// contains filtered or unexported fields
}

Manager encapsulates shared ConfigMap loading, caching, and reconcile logic for operator configuration structs.

func NewManager

func NewManager[T any](opts Options[T]) (*Manager[T], error)

NewManager constructs a Manager with the provided options.

func (*Manager[T]) CurrentConfig

func (m *Manager[T]) CurrentConfig() *T

CurrentConfig returns a cloned snapshot of the cached configuration.

func (*Manager[T]) LoadInitial

func (m *Manager[T]) LoadInitial(ctx context.Context) error

LoadInitial synchronously loads the ConfigMap before the manager starts.

func (*Manager[T]) Reconcile

func (m *Manager[T]) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

Reconcile reacts to ConfigMap updates/deletes and refreshes the cache.

func (*Manager[T]) ResetToDefault

func (m *Manager[T]) ResetToDefault()

ResetToDefault replaces the cached configuration with the default snapshot.

func (*Manager[T]) SetAPIReader

func (m *Manager[T]) SetAPIReader(reader client.Reader)

SetAPIReader injects a non-cached reader for startup scenarios.

func (*Manager[T]) SetupWithManager

func (m *Manager[T]) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager wires the manager into controller-runtime so ConfigMap changes trigger reconciles.

type Options

type Options[T any] struct {
	Client          client.Client
	Logger          logr.Logger
	ConfigMapKey    types.NamespacedName
	ControllerName  string
	DefaultConfig   func() *T
	ParseConfigMap  func(*corev1.ConfigMap) (*T, error)
	CloneConfig     func(*T) *T
	ApplyConfig     func(*T)
	OnConfigApplied func(ReloadReason, *T)
}

Options configures a Manager instance for a concrete operator config type.

type ReloadReason

type ReloadReason string

ReloadReason identifies why the configuration was reloaded.

const (
	// ReloadReasonInitial indicates the initial synchronous load at startup.
	ReloadReasonInitial ReloadReason = "initial"
	// ReloadReasonReconcile indicates a reload triggered by the controller watch.
	ReloadReasonReconcile ReloadReason = "reconcile"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL