loader

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package loader reads a atago YAML file and turns it into a validated *spec.Spec. Validation happens in layers: YAML parse, then schema/semantic checks. Errors carry the file path and, for parse failures, the line/column reported by goccy/go-yaml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(path string) (*spec.Spec, error)

Load reads and validates the spec file at path.

func LoadBytes

func LoadBytes(path string, data []byte) (*spec.Spec, error)

LoadBytes parses and validates spec bytes, labeling errors with path.

Types

type Error

type Error struct {
	Path string
	Kind Kind
	Msg  string
}

Error is a loader failure annotated with the source path and kind.

func (*Error) Error

func (e *Error) Error() string

type Kind

type Kind int

Kind classifies why loading failed, so callers can map it to an exit code (exit 2 = spec parse error).

const (
	// KindParse is a YAML syntax or decode error.
	KindParse Kind = iota
	// KindValidation is a schema or semantic error in an otherwise-parseable file.
	KindValidation
)

type Position

type Position struct {
	Line   int
	Column int
}

Position is a 1-based source location. A zero Line means "unknown".

type Source

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

Source resolves stable source locations (line and column) for the declarations in a spec file, so tooling can jump from a manifest entry straight to the authored YAML (#80). It is built from the same bytes the spec was decoded from and answers queries by YAML path against the parsed AST.

A location is 1-based and points at the value token for the queried node (for a scenario, the `name:` value; for a step, the step mapping). When a path cannot be resolved — e.g. an optional block is absent — the position is zero, which callers treat as "unknown" and omit.

func LoadWithSource

func LoadWithSource(path string) (*spec.Spec, *Source, error)

LoadWithSource loads and validates the spec at path and also returns a Source locator for it. The spec is identical to what Load returns; the extra Source exposes authored line/column positions. A parse error for the position AST is non-fatal (the spec already decoded), so Source methods simply report unknown.

func (*Source) RunnerPos

func (s *Source) RunnerPos(name string) (line, column int)

RunnerPos returns the location of a named runner declaration.

func (*Source) ScenarioPos

func (s *Source) ScenarioPos(authoredIndex int) (line, column int)

ScenarioPos returns the location of the authored scenario at authoredIndex (its pre-matrix-expansion index). Every instance expanded from one matrix template shares this location.

func (*Source) StepPos

func (s *Source) StepPos(authoredScenarioIndex, stepIndex int) (line, column int)

StepPos returns the location of step stepIndex within the authored scenario at authoredScenarioIndex.

func (*Source) SuitePos

func (s *Source) SuitePos() (line, column int)

SuitePos returns the location of the suite declaration.

Jump to

Keyboard shortcuts

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