Help us shape the future of Go! Take the 2026 Go Developer Survey

configtest

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package configtest runs a HAProxyTemplateConfig's embedded validationTests against an already-built engine, bounded by a timeout. It backs pkg/controller/validator.RunValidationTestsSync, which both the startup load gate and the live config-change gate run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// Passed is true when every test passed AND the run completed. A config with
	// no validationTests passes trivially.
	Passed bool

	// Failures holds bounded, human-readable summaries of the failed tests.
	// Non-empty only when Passed is false and Incomplete is false.
	Failures []string

	// Incomplete is true when the run was cut short by the timeout before every
	// test finished. The caller owns the fail-closed (reject) vs fail-open
	// (admit-with-warning) decision: the daemon load gate fails closed; the
	// admission webhook fails open so a slow suite never blocks an apply.
	Incomplete bool
}

Result is the outcome of running a config's validationTests.

func RunValidationTests

func RunValidationTests(
	ctx context.Context,
	cfg *config.Config,
	engine templating.Engine,
	typedResourceTypes map[string]reflect.Type,
	timeout time.Duration,
	logger *slog.Logger,
) (Result, error)

RunValidationTests executes cfg's embedded validationTests against the given (already-compiled) engine, bounded by timeout. typedResourceTypes carries the per-resource typed reflect.Types so the test render context matches the typed globals the engine compiled against. It builds and tears down a temporary HAProxy validation tree for `haproxy_valid` assertions.

Returns Passed=true immediately when the config declares no validationTests.

Jump to

Keyboard shortcuts

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