Documentation
¶
Index ¶
Constants ¶
const ( // ComponentName is the unique identifier for this component. ComponentName = "credentialsloader" // EventBufferSize is the size of the event subscription buffer. // Size 50: Low-volume component (~1 event per secret change). EventBufferSize = 50 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CredentialsLoaderComponent ¶
type CredentialsLoaderComponent struct {
// contains filtered or unexported fields
}
CredentialsLoaderComponent subscribes to SecretResourceChangedEvent and parses Secret data.
This component is responsible for: - Extracting credentials from Secret resources - Parsing Secret data into config.Credentials structures - Publishing CredentialsUpdatedEvent for successfully loaded credentials - Publishing CredentialsInvalidEvent for invalid credentials
Architecture: This is a pure event-driven component with no knowledge of watchers or Kubernetes. It simply reacts to SecretResourceChangedEvent and produces CredentialsUpdatedEvent or CredentialsInvalidEvent.
func NewCredentialsLoaderComponent ¶
func NewCredentialsLoaderComponent(eventBus *busevents.EventBus, logger *slog.Logger) *CredentialsLoaderComponent
NewCredentialsLoaderComponent creates a new CredentialsLoader component.
Parameters:
- eventBus: The EventBus to subscribe to and publish on
- logger: Structured logger for diagnostics
Returns:
- *CredentialsLoaderComponent ready to start
func (*CredentialsLoaderComponent) Start ¶
func (c *CredentialsLoaderComponent) Start(ctx context.Context) error
Start begins processing events from the EventBus.
This method blocks until Stop() is called or the context is canceled. The component is already subscribed to the EventBus (subscription happens in constructor). Returns nil on graceful shutdown.
Example:
go component.Start(ctx)
func (*CredentialsLoaderComponent) Stop ¶
func (c *CredentialsLoaderComponent) Stop()
Stop gracefully stops the component.
type SecretWatcher ¶
type SecretWatcher struct {
// contains filtered or unexported fields
}
SecretWatcher watches a specific Secret and publishes SecretResourceChangedEvent.
This component bridges the Kubernetes informer pattern with the controller's event-driven architecture. It watches a single Secret (referenced by HAProxyTemplateConfig.CredentialsSecretRef) and publishes events whenever the Secret is added, updated, or deleted.
Architecture: - Uses core Kubernetes informers (not generated) - Publishes SecretResourceChangedEvent (consumed by CredentialsLoaderComponent) - Converts typed Secret to unstructured format for consistent handling.
func NewSecretWatcher ¶
func NewSecretWatcher( client kubernetes.Interface, eventBus *busevents.EventBus, logger *slog.Logger, namespace string, name string, ) *SecretWatcher
NewSecretWatcher creates a new SecretWatcher.
Parameters:
- client: Kubernetes client
- eventBus: EventBus to publish SecretResourceChangedEvent
- logger: Structured logger for diagnostics
- namespace: Namespace containing the Secret
- name: Name of the Secret to watch
Returns:
- *SecretWatcher ready to start
func (*SecretWatcher) Start ¶
func (w *SecretWatcher) Start(ctx context.Context) error
Start begins watching the Secret.
This method blocks until Stop() is called or the context is canceled. It should typically be run in a goroutine.
Example:
watcher := NewSecretWatcher(client, bus, logger, "default", "haproxy-credentials") go watcher.Start(ctx)