drill

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package drill holds the drill file format and its validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasErrors

func HasErrors(issues []Issue) bool

HasErrors reports whether any issue is an error rather than a warning.

func Hash

func Hash(data []byte) string

Hash returns the SHA-256 of a drill file's bytes.

func Load

func Load(file string, data []byte) (*Drill, []Issue)

Load parses and validates one drill.

func LoadDir

func LoadDir(dir string) ([]*Drill, []Issue, error)

LoadDir reads every *.drill.yaml below a directory, sorted by path.

func Parse

func Parse(file string, data []byte) (*Drill, []Issue)

Parse reads one drill file. Every structural problem is returned as an Issue with its line, so a broken file reports all it can in one pass.

func UsedPaths

func UsedPaths(d *Drill) map[string][]string

UsedPaths returns, per fetch alias, the field paths a drill's conditions read.

func VersionAtLeast

func VersionAtLeast(v, min string) bool

VersionAtLeast reports whether version v is at least min. Both are x.y.z, with an optional leading v and any suffix after the patch number ignored.

Types

type Condition

type Condition struct {
	Expr string
	Line int
}

Condition is one CEL expression with the line it came from.

type Drill

type Drill struct {
	Firedrill   string
	ID          string
	Safeguard   string
	Source      string
	Owner       string
	Severity    string
	ForEach     string
	Fetches     []Fetch
	AppliesWhen *Condition
	NAReason    string
	PassWhen    []Condition
	WarnWhen    []Condition
	Fix         string
	MapsTo      []string
	Author      string // who wrote it, for hub drills
	Requires    string // the oldest Firedrill it runs on, as ">= x.y.z"
	File        string
	Hash        string
}

Drill is one parsed drill file.

func (*Drill) MinVersion

func (d *Drill) MinVersion() string

MinVersion returns the version a requires field names, or "" when absent.

type Evaluator

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

Evaluator evaluates one drill's conditions over fact data.

func NewEvaluator

func NewEvaluator(d *Drill) (*Evaluator, error)

NewEvaluator returns an Evaluator for a drill.

func (*Evaluator) Eval

func (e *Evaluator) Eval(expr string, vars map[string]any) (bool, error)

Eval runs one condition. A missing field, a non-bool result or an exceeded cost limit is an error, so a typo can never pass quietly.

type Fetch

type Fetch struct {
	Alias string
	Fact  string
	Args  map[string]string
	Line  int
}

Fetch is one named fact a drill reads.

type Issue

type Issue struct {
	File    string
	Line    int
	Message string
	Warning bool
}

Issue is one problem found in a drill file.

func Validate

func Validate(d *Drill) []Issue

Validate checks a parsed drill against the list of facts and fields.

func (Issue) String

func (i Issue) String() string

Jump to

Keyboard shortcuts

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