yamlsubset

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package yamlsubset is the loader's one rule for issue #88: the strict YAML subset §3 states. YAML is parsed strictly — an anchor, an alias, a merge key, a tag, a multi-document file, or implicit type resolution is strict-yaml-violation, positioned at the file, line and column it occurs on (ADR-0023). This package knows nothing about any artefact schema — that is internal/schema and internal/artefact's rule (issue #89) — but it exposes the node its own decode produces, Parse, so a caller checking both this package's grammar and an artefact's schema reads the file once.

Index

Constants

View Source
const ErrorCode = "strict-yaml-violation"

ErrorCode is the one code this package emits.

Variables

This section is empty.

Functions

func Parse

func Parse(file string, data []byte) (root *yaml.Node, problems []problem.Problem, ok bool)

Parse decodes data as YAML and returns the first document's root content node together with the load-time problems this package reports at that granularity. ok is false where the file will not parse at all — a hard YAML syntax error — which is the one case "loading a file is the first check, and failing it stops every check after" names (§4): root is nil, problems holds exactly one entry, and neither this package's own walk nor the schema check that reads the same node (issue #89) runs. ok is true and root is nil where the file is empty: zero documents is valid YAML, and whether it is a valid artefact is a schema question this package does not answer. A file holding more than one YAML document is ok, with a problem for the second document and the first document's node returned all the same.

Parse walks nothing itself, so a caller that needs both this package's grammar rules and the schema check reads the file once rather than twice: Scan below calls Violations on the node it returns.

func Scan

func Scan(file string, data []byte) []problem.Problem

Scan reads data as YAML and returns one problem per construct the strict subset rejects. A file that will not parse at all — a hard YAML syntax error — yields exactly one problem and scanning stops there, since the parser has nothing more to walk (issue #88's "an artefact whose own file will not parse still declares its name and yields exactly one problem"). A syntactically valid file that uses a forbidden construct more than once yields one problem per occurrence.

func Violations

func Violations(root *yaml.Node, file string) []problem.Problem

Violations walks root for the strict-subset grammar and returns one problem per rejected construct — Scan's own walk, exposed so a caller that already holds root from Parse does not decode the file a second time (issue #89).

Types

This section is empty.

Jump to

Keyboard shortcuts

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