validators

package
v0.10.13 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package validators provides shared utilities for v2 validator containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(checks map[string]CheckFunc)

Run is the main entry point for v2 validator containers. It loads the context, dispatches to the named check, and handles exit codes and termination log writing.

Usage in main.go:

func main() {
    validators.Run(map[string]validators.CheckFunc{
        "operator-health":    checkOperatorHealth,
        "expected-resources": checkExpectedResources,
    })
}

func Skip

func Skip(reason string) error

Skip returns a skip sentinel error with the given reason. When returned from a CheckFunc, the runner exits with code 2 (skip).

Types

type CheckFunc

type CheckFunc func(ctx *Context) error

CheckFunc is the signature for a v2 validator check function. Return nil for pass, non-nil error for fail, Skip() for skip. Evidence goes to stdout, debug logs to stderr.

type Context

type Context struct {
	// Ctx is the parent context with timeout.
	Ctx context.Context

	// Cancel releases resources. Must be called when done.
	Cancel context.CancelFunc

	// Clientset is the Kubernetes typed client.
	Clientset kubernetes.Interface

	// RESTConfig is the Kubernetes REST config (for exec, dynamic client, etc.).
	RESTConfig *rest.Config

	// DynamicClient is the Kubernetes dynamic client for CRD access.
	DynamicClient dynamic.Interface

	// Snapshot is the captured cluster state.
	Snapshot *snapshotter.Snapshot

	// Recipe is the recipe with validation configuration.
	Recipe *recipe.RecipeResult

	// Namespace is the validation namespace.
	Namespace string
}

Context holds all dependencies for a validator check function.

func LoadContext

func LoadContext() (*Context, error)

LoadContext creates a Context from the v2 container environment. Reads snapshot and recipe from mounted ConfigMap paths. Builds a K8s client from in-cluster config or KUBECONFIG.

The caller MUST call ctx.Cancel() when done.

func (*Context) Timeout

Timeout returns a child context with the specified timeout. The caller is responsible for calling the returned CancelFunc.

Directories

Path Synopsis
Package chainsaw executes Chainsaw-style assertions against a live Kubernetes cluster.
Package chainsaw executes Chainsaw-style assertions against a live Kubernetes cluster.
conformance is a validator container for all conformance phase checks.
conformance is a validator container for all conformance phase checks.
deployment is a validator container for all deployment phase checks.
deployment is a validator container for all deployment phase checks.
Package helper provides shared utilities for v2 validator containers.
Package helper provides shared utilities for v2 validator containers.
performance is a validator container for all performance phase checks.
performance is a validator container for all performance phase checks.

Jump to

Keyboard shortcuts

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