Documentation
¶
Overview ¶
Package configtest runs a HAProxyTemplateConfig's embedded validationTests against an already-built engine, bounded by a timeout. It is the single source of truth shared by the two places the controller gates on validationTests:
- the daemon load gate (pkg/controller/validator.ValidationTestsValidator), which refuses to load a config whose tests fail; and
- the admission webhook (pkg/controller/webhook.ConfigValidator), which refuses to ADMIT such a config so it never enters etcd.
Running the identical check in both places is what makes them consistent: a config the webhook admits will load — there's no "admitted but later rejected" gap that would leave a latent bad config to crash-loop the next fresh controller pod.
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.