proposalvalidator

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

pkg/controller/proposalvalidator

Validates hypothetical configuration changes by rendering live stores with temporary overlays. Service owns validation; Component connects it to proposal events.

Validation policies

Caller Entry point Failure policy
Admission webhook Service.ValidateSyncWithAdmissionSubject Checks observed inputs, then retries with only exact rejected revisions withheld
Background HTTP refresh Component handling ProposalValidationRequestedEvent Rejects invalid proposed output, including output identical to an invalid baseline

The observed-input path retains its exact unchanged-output comparison. The isolated-input fallback must produce valid output; it never uses that exception. ObservedStoreProvider keeps admission snapshots in the reconciliation revision family. AdmissionStoreProvider preserves all observed changes except exact rejected revisions; AcceptedStoreProvider supplies validated inputs for HTTP content proposals.

Cancellation and unavailable published files reject admission. Neither can use the unchanged-invalid exception. CurrentFilesProvider supplies one snapshot per decision, shared by the proposed and baseline renders.

Admission service

service := proposalvalidator.NewService(&proposalvalidator.ServiceConfig{
    Pipeline:             admissionPipeline,
    BaseStoreProvider:    storeProvider,
    CurrentFilesProvider: currentFilesProvider,
    Logger:               logger,
})
pipelineResult, result := service.ValidateSync(ctx, overlays)

The service has no event subscription or lifecycle. ValidateSync returns (*pipeline.PipelineResult, *validation.ValidationResult). An admitted result includes the proposed rendered output, including when admission uses the unchanged-invalid exception. Rejections include the failing phase, error, and any warnings.

HTTP-content event adapter

adapter := proposalvalidator.New(eventBus, &proposalvalidator.ServiceConfig{
    Pipeline:             proposalPipeline,
    BaseStoreProvider:    storeProvider,
    CurrentFilesProvider: currentFilesProvider,
    Logger:               logger,
})
eventBus.Start()
go adapter.Start(ctx)

Construct every subscriber before starting the event bus. The adapter publishes a verdict carrying the request ID, including when validation panics. Cancelling its lifecycle context cancels active validation.

  • pipeline — render and validation execution
  • dryrunvalidator — admission overlays and error reporting
  • httpstore — pending HTTP-content promotion
  • stores — temporary resource and HTTP overlays

Documentation

Overview

Package proposalvalidator validates hypothetical configuration changes.

Index

Constants

View Source
const (
	ComponentName   = "proposalvalidator"
	EventBufferSize = busevents.StandardSubscriberBuffer
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	*component.Base
	// contains filtered or unexported fields
}

Component adapts proposal-validation requests to the validation service.

func New

func New(eventBus *busevents.EventBus, cfg *ServiceConfig) *Component

New subscribes to proposal-validation requests during construction.

func (*Component) HandleEvent

func (c *Component) HandleEvent(event busevents.Event)

HandleEvent implements component.EventHandler: it processes incoming events.

func (*Component) HandlePanic

func (c *Component) HandlePanic(recovered any, event busevents.Event)

HandlePanic rejects the request so pending HTTP content receives a verdict.

type Service

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

Service validates proposed changes against the current stores.

func NewService

func NewService(cfg *ServiceConfig) *Service

NewService creates a validator without an event subscription or lifecycle.

func (*Service) ValidateSync

ValidateSync admits unchanged invalid output only after an exact baseline comparison.

func (*Service) ValidateSyncWithAdmissionSubject

func (c *Service) ValidateSyncWithAdmissionSubject(ctx context.Context, overlays map[string]*stores.StoreOverlay, storeAliases []string, namespace, name string) (*pipeline.PipelineResult, *validation.ValidationResult)

ValidateSyncWithAdmissionSubject validates one admitted object across every configured store alias affected by the request.

type ServiceConfig

type ServiceConfig struct {
	Pipeline          *pipeline.Pipeline
	BaseStoreProvider stores.StoreProvider
	// FreshStoreProvider supplies API-backed inputs when a cached render rejects admission.
	FreshStoreProvider func(context.Context) (stores.StoreProvider, error)
	// AcceptedStoreProvider supplies inputs that passed complete output validation.
	AcceptedStoreProvider func() (stores.StoreProvider, bool)
	// AdmissionStoreProvider excludes only rejected revisions from observed inputs.
	AdmissionStoreProvider func(context.Context, stores.StoreProvider) (stores.StoreProvider, bool, error)
	// ObservedStoreProvider preserves the reconciliation input revision family.
	ObservedStoreProvider func(context.Context, stores.StoreProvider) (stores.StoreProvider, error)
	// CurrentFilesProvider pins one published baseline across both renders.
	CurrentFilesProvider func() (map[string]string, error)
	Logger               *slog.Logger
}

ServiceConfig supplies the validation pipeline and its inputs.

Jump to

Keyboard shortcuts

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