pipeline

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: 9 Imported by: 0

Documentation

Overview

Package pipeline provides the render-validate pipeline for HAProxy configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pipeline

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

Pipeline composes render and validate services into a single workflow.

The pipeline: 1. Renders HAProxy configuration from stores 2. Validates the rendered configuration 3. Returns combined result

This is a pure service with no event dependencies. It can be used by: - ReconciliationCoordinator for normal reconciliation flow - ProposalValidator for validation-only requests.

func New

func New(cfg *PipelineConfig) *Pipeline

New creates a new render-validate pipeline.

Panics if Renderer or Validator is nil. This is intentional: these are required dependencies, and failing at construction time is clearer than returning errors at execution time.

func (*Pipeline) Execute

func (p *Pipeline) Execute(ctx context.Context, provider stores.StoreProvider) (*PipelineResult, error)

Execute runs the render-validate pipeline.

The render mode (production vs validation) is determined automatically: - If provider is *OverlayStoreProvider with overlays: validation mode - Otherwise: production mode

Parameters:

  • ctx: Context for cancellation
  • provider: StoreProvider for accessing resource stores

Returns:

  • PipelineResult containing rendered config and validation status
  • Error if rendering or validation fails

func (*Pipeline) ExecuteWithResult

func (p *Pipeline) ExecuteWithResult(ctx context.Context, provider stores.StoreProvider) (*PipelineResult, *validation.ValidationResult, error)

ExecuteWithResult runs the pipeline and returns validation result even on failure. This is useful when you need details about why validation failed.

The render mode (production vs validation) is determined automatically: - If provider is *OverlayStoreProvider with overlays: validation mode - Otherwise: production mode

Parameters:

  • ctx: Context for cancellation
  • provider: StoreProvider for accessing resource stores

Returns:

  • PipelineResult with config and timing (nil if render failed)
  • ValidationResult with validation details (nil if render failed)
  • Error if rendering fails (validation failures return non-nil ValidationResult)

func (*Pipeline) RenderOnly

func (p *Pipeline) RenderOnly(ctx context.Context, provider stores.StoreProvider) (*renderer.RenderResult, error)

RenderOnly renders configuration without validation. Use this when you need to inspect the rendered output without validation.

Parameters:

  • ctx: Context for cancellation
  • provider: StoreProvider for accessing resource stores

Returns:

  • RenderResult from the render service
  • Error if rendering fails

func (*Pipeline) ValidateConfig

func (p *Pipeline) ValidateConfig(ctx context.Context, config string, auxFiles *dataplane.AuxiliaryFiles) *validation.ValidationResult

ValidateConfig validates a pre-rendered configuration. Use this when you already have rendered config and just need validation.

Parameters:

  • ctx: Context for cancellation
  • config: The HAProxy configuration content
  • auxFiles: Auxiliary files for the configuration

Returns:

  • ValidationResult with validation details

type PipelineConfig

type PipelineConfig struct {
	// Renderer is the render service for generating configuration.
	Renderer *renderer.RenderService

	// Validator is the validation service for checking configuration.
	Validator *validation.ValidationService

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

PipelineConfig contains configuration for creating a Pipeline.

type PipelineError

type PipelineError struct {
	// Phase identifies which pipeline phase failed.
	Phase PipelinePhase

	// ValidationPhase is set when Phase is PhaseValidation.
	// It contains the specific validation sub-phase (syntax, schema, semantic).
	ValidationPhase string

	// Cause is the underlying error.
	Cause error
}

PipelineError is a structured error that identifies which pipeline phase failed. Callers can use errors.As() to extract phase information instead of string parsing.

func (*PipelineError) Error

func (e *PipelineError) Error() string

Error implements the error interface.

func (*PipelineError) Unwrap

func (e *PipelineError) Unwrap() error

Unwrap returns the underlying error for errors.Is/As compatibility.

type PipelinePhase

type PipelinePhase string

PipelinePhase identifies which phase of the pipeline failed.

const (
	// PhaseRender indicates the render phase.
	PhaseRender PipelinePhase = "render"
	// PhaseValidation indicates the validation phase.
	PhaseValidation PipelinePhase = "validation"
)

type PipelineResult

type PipelineResult struct {
	// HAProxyConfig is the rendered HAProxy configuration.
	HAProxyConfig string

	// AuxiliaryFiles contains all rendered auxiliary files.
	AuxiliaryFiles *dataplane.AuxiliaryFiles

	// AuxFileCount is the total number of auxiliary files.
	AuxFileCount int

	// ContentChecksum is the pre-computed content checksum covering config + aux files.
	// Computed once in the pipeline and propagated through events to downstream consumers,
	// eliminating redundant hashing across validation, publishing, and deployment.
	ContentChecksum string

	// RenderDurationMs is the rendering duration in milliseconds.
	RenderDurationMs int64

	// ValidateDurationMs is the validation duration in milliseconds.
	ValidateDurationMs int64

	// TotalDurationMs is the total pipeline duration in milliseconds.
	TotalDurationMs int64

	// ValidationPhase indicates which validation phase completed last.
	// Empty string means all phases passed.
	ValidationPhase string

	// ParsedConfig is the pre-parsed desired configuration from syntax validation.
	// May be nil if validation cache was used.
	// When non-nil, can be passed to downstream sync operations to avoid re-parsing.
	ParsedConfig *parser.StructuredConfig
}

PipelineResult contains the output of a render-validate pipeline execution.

Jump to

Keyboard shortcuts

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