installvalidate

package
v0.19.1052 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package installvalidate validates an install's desired configuration before it is persisted, surfacing structural problems as a set of diagnostics rather than a single opaque error. It is modelled loosely on HCL's diagnostics: each problem is a self-describing record (severity, code, summary, detail, the components involved) and a run aggregates every problem instead of failing on the first.

Validation reasons about the install's DESIRED state (the component toggles in InstallConfig), never the actual deployment state. It is intended to gate the authoritative mutation paths — install-config sync and the component toggle endpoint — so a stored install can never reach a structurally invalid state.

Index

Constants

View Source
const CodeDisabledDependency = "disabled_dependency"

CodeDisabledDependency marks an invalid dependency edge: an enabled component that depends on a disabled one. Both toggle rules below describe this same structural edge from opposite ends, so they share this code and dedup to a single diagnostic per edge during a full sync.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Resolver *appconfiggraph.ComponentEnablementResolver
	CCCByID  map[string]*app.ComponentConfigConnection
	Op       Operation
}

Context carries everything the rules need to evaluate an install's desired state: the dependency/enablement resolver, the component config snapshot, and the operation being validated.

func NewContext

func NewContext(cccByID map[string]*app.ComponentConfigConnection, enabledInputs map[string]*string, op Operation) *Context

NewContext builds a validation context from the install's pinned app-config snapshot (component-ID keyed) and the install's input values, which carry the per-component enabled toggles.

type Diagnostic

type Diagnostic struct {
	Severity Severity `json:"severity"`
	// Code is a stable, machine-readable identifier for the kind of problem.
	Code string `json:"code"`
	// Summary is a short, user-facing description of the problem.
	Summary string `json:"summary"`
	// Detail optionally explains how to resolve the problem.
	Detail string `json:"detail,omitempty"`
	// Components are the user-facing component names involved in the problem.
	Components []string `json:"components,omitempty"`
}

Diagnostic is a single self-describing validation problem.

type Diagnostics

type Diagnostics []Diagnostic

Diagnostics is an aggregated set of validation problems.

func (Diagnostics) Error

func (ds Diagnostics) Error() string

Error renders the diagnostics as a single aggregated message so a non-empty Diagnostics value can be returned where an error is expected.

func (Diagnostics) Errors

func (ds Diagnostics) Errors() Diagnostics

func (Diagnostics) HasErrors

func (ds Diagnostics) HasErrors() bool

type DisableRequiresDependentsDisabledRule

type DisableRequiresDependentsDisabledRule struct{}

DisableRequiresDependentsDisabledRule enforces that a component may only be disabled when no component that depends on it is still enabled — the "a parent cannot be disabled while a child is enabled" scenario. On a disable operation it scopes to the toggled component; on a full sync it evaluates every component.

func (DisableRequiresDependentsDisabledRule) Check

func (DisableRequiresDependentsDisabledRule) Name

type EnableRequiresDependenciesEnabledRule

type EnableRequiresDependenciesEnabledRule struct{}

EnableRequiresDependenciesEnabledRule enforces that a component may only be enabled when every component it depends on is also enabled — the "a child cannot be enabled while a parent is disabled" scenario. On an enable operation it scopes to the toggled component; on a full sync it evaluates every component.

func (EnableRequiresDependenciesEnabledRule) Check

func (EnableRequiresDependenciesEnabledRule) Name

type Operation

type Operation struct {
	Kind OperationKind
	// ComponentID is the component being toggled for OperationEnable/Disable.
	ComponentID string
}

Operation describes the mutation being validated.

type OperationKind

type OperationKind int

OperationKind identifies the mutation being validated, which scopes how the rules render. A full sync evaluates the whole graph; an enable/disable scopes to the single component being toggled so an unrelated pre-existing problem elsewhere never blocks a targeted toggle.

const (
	OperationSync OperationKind = iota
	OperationEnable
	OperationDisable
)

type Rule

type Rule interface {
	Name() string
	Check(*Context) Diagnostics
}

Rule is a single validation check over the desired install state. New validation scenarios (beyond component toggles) are added by implementing Rule and registering it with a Validator.

type Severity

type Severity string
const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
)

type Validator

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

Validator runs an ordered set of rules and aggregates their diagnostics.

func DefaultValidator

func DefaultValidator() *Validator

DefaultValidator returns the validator with the standard install rules.

func New

func New(rules ...Rule) *Validator

func (*Validator) Validate

func (v *Validator) Validate(c *Context) Diagnostics

Validate runs every rule and returns the deduplicated diagnostics.

Jump to

Keyboard shortcuts

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