proposalvalidator

package
v0.1.0-alpha.12 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package proposalvalidator provides validation of hypothetical configuration changes.

Index

Constants

View Source
const (
	// ComponentName is the unique identifier for this component.
	ComponentName = "proposalvalidator"

	// EventBufferSize is the buffer size for event channel.
	EventBufferSize = 50
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	// contains filtered or unexported fields
}

Component validates hypothetical configuration changes without deploying.

It supports two modes:

  1. Async (event-driven): Subscribes to ProposalValidationRequestedEvent and publishes ProposalValidationCompletedEvent.
  2. Sync (direct call): ValidateSync() for synchronous callers like webhooks.

The component uses RenderValidatePipeline with CompositeStoreProvider to render and validate configurations with proposed changes overlaid on actual stores.

func New

func New(cfg *ComponentConfig) *Component

New creates a new ProposalValidator component.

For async mode (SyncOnly=false): The component subscribes to events during construction (before EventBus.Start()) to ensure proper startup synchronization. Call Start() to begin processing events.

For sync-only mode (SyncOnly=true): No event subscription occurs. Only ValidateSync() can be used. Do not call Start().

func (*Component) Name

func (c *Component) Name() string

Name returns the unique identifier for this component. Implements the lifecycle.Component interface.

func (*Component) Start

func (c *Component) Start(ctx context.Context) error

Start runs the component's event loop.

It listens for ProposalValidationRequestedEvent and processes validation requests.

func (*Component) ValidateSync

func (c *Component) ValidateSync(ctx context.Context, overlays map[string]*stores.StoreOverlay) *validation.ValidationResult

ValidateSync performs synchronous validation of proposed changes.

This is the preferred method for webhook admission where the caller needs an immediate response. Unlike event-driven validation, this blocks until validation completes.

Parameters:

  • ctx: Context for cancellation
  • overlays: Map of store name to proposed changes

Returns:

  • ValidationResult with valid/invalid status and error details.

type ComponentConfig

type ComponentConfig struct {
	// EventBus is the event bus for async validation requests.
	// Required for async mode, optional for sync-only mode.
	EventBus *busevents.EventBus

	// Pipeline is the render-validate pipeline.
	Pipeline *pipeline.Pipeline

	// BaseStoreProvider is the provider for actual (non-overlaid) stores.
	BaseStoreProvider stores.StoreProvider

	// Logger is the structured logger for logging.
	Logger *slog.Logger

	// SyncOnly, when true, creates a validator that only supports ValidateSync().
	// It does not subscribe to EventBus events and Start() should not be called.
	// Use this mode when only synchronous validation is needed (e.g., webhook).
	SyncOnly bool
}

ComponentConfig contains configuration for creating a ProposalValidator.

Jump to

Keyboard shortcuts

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