validation

package
v1.223.1-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package validation contains provider-neutral validation diagnostics and their common output representations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AffectedFiles

func AffectedFiles(base string) ([]string, error)

AffectedFiles returns repository-relative files changed between HEAD and its merge-base with base. When base is empty, it uses the GitHub event's base SHA (when available), then the GitHub base branch, and finally origin/HEAD.

Deleted paths are intentionally retained. Callers can use them to decide whether a dependent validator must run, while skipping files that can no longer be read.

func ExcludePaths

func ExcludePaths(paths []string, patterns []string) ([]string, error)

ExcludePaths removes paths matching any repository-relative glob pattern. Patterns use forward slashes and support doublestar (for example, "tests/fixtures/**") on every platform.

func IsAtmosConfigPath

func IsAtmosConfigPath(path string) bool

IsAtmosConfigPath reports whether path is one of the project-local Atmos configuration files read by the CLI configuration loader.

func Rich

func Rich(report Report, options RichOptions) string

Rich renders a report as deterministic source excerpts. It intentionally degrades to a complete header-only finding when a source cannot be read; presentation must never hide a validation failure.

Types

type Diagnostic

type Diagnostic struct {
	Source   string
	RuleID   string
	Severity Severity
	Message  string
	File     string
	Line     int
	Column   int
	// EndLine and EndColumn optionally identify a multi-line finding. They are
	// primarily used by human renderers and CI annotations; zero means the
	// location ends at Line/Column.
	EndLine   int
	EndColumn int
}

Diagnostic is a source location and message emitted by a validator.

type Report

type Report struct {
	Diagnostics         []Diagnostic
	FilesChecked        int
	Target              string
	RenderedDiagnostics string
}

Report is the complete result of one validator invocation.

func FromGCCText

func FromGCCText(source, message string) Report

FromGCCText converts the location-bearing text produced by existing stack validation into normalized diagnostics. Lines that do not carry a source location become a single file-less finding so rich output never discards useful validation context.

func (Report) HasErrors

func (r Report) HasErrors() bool

HasErrors reports whether the report contains at least one error.

func (Report) SARIF

func (r Report) SARIF() ([]byte, error)

SARIF serializes the report as an indented SARIF 2.1.0 document.

func (Report) ToAnnotations

func (r Report) ToAnnotations() []ci.Annotation

ToAnnotations maps the report to provider-neutral CI annotations.

type RichOptions

type RichOptions struct {
	Root  string
	Width int
	Color bool
}

RichOptions controls a human-oriented diagnostic rendering. Root resolves relative diagnostic paths, Width is the available terminal width (or zero for the standard fallback), and Color is normally derived from Atmos's terminal policy by callers.

func DefaultRichOptions

func DefaultRichOptions(root string) RichOptions

DefaultRichOptions obtains the standard terminal capabilities. Keeping this separate lets tests and command callers supply deterministic settings.

type Severity

type Severity string

Severity is the normalized severity of a validation finding.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityNotice  Severity = "notice"
)

Jump to

Keyboard shortcuts

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