query

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 7 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 query parses strata's filter language and compiles it to SQL, so every filter runs inside DuckDB rather than in application memory.

label.team = "payments" and age > 180d
ancestor("reg.io/base/go:1.21") and not has:sbom
stale in ["stale", "abandoned"] and label.env = "prod"
root ~ "reg.io/base/debian:*" and label.deprecated exists

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expr

func Expr(name string) (string, error)

Expr returns the SQL expression for a field, for use in SELECT, GROUP BY and ORDER BY. Ref fields return the parent or root digest.

func IsList

func IsList(name string) bool

IsList reports whether a field holds several values per image, so a group-by over it must unnest.

func ParseBytes

func ParseBytes(s string) (int64, error)

ParseBytes parses a size: 512, 10KB, 1.5GiB.

func ParseDays

func ParseDays(s string) (float64, error)

ParseDays parses a duration as days: 180d, 12h, 6w, 3mo, 1y, or a plain number of days.

Types

type And

type And struct{ L, R Node }

And matches when both sides match.

func (And) String

func (n And) String() string

String formats an And.

type Call

type Call struct {
	Name string
	Args []Value
	Pos  int
}

Call is a function such as ancestor("reg.io/base/go:1.21").

func (Call) String

func (n Call) String() string

String formats a Call.

type Compare

type Compare struct {
	Field string
	Op    string
	Value Value
	Pos   int
}

Compare is field op value, such as age > 180d.

func (Compare) String

func (n Compare) String() string

String formats a Compare.

type Compiled

type Compiled struct {
	Where string
	Args  []any
}

Compiled is a WHERE clause and its positional arguments.

func Compile

func Compile(src string) (Compiled, error)

Compile parses and compiles a filter. An empty filter compiles to "true".

func CompileNode

func CompileNode(n Node) (Compiled, error)

CompileNode compiles a parsed filter.

type Exists

type Exists struct {
	Field string
	Pos   int
}

Exists is field exists.

func (Exists) String

func (n Exists) String() string

String formats an Exists.

type Field

type Field struct {
	Name string
	Doc  string
	// contains filtered or unexported fields
}

Field describes one queryable field.

func Fields

func Fields() []Field

Fields returns every static field plus the label.<key> and missing:<key> patterns, sorted by name, for help and docs.

func Lookup

func Lookup(name string) (Field, error)

Lookup resolves a field name, including label.<key> and missing:<key>.

type Flag

type Flag struct {
	Field string
	Pos   int
}

Flag is a field used on its own as a condition, such as has:sbom.

func (Flag) String

func (n Flag) String() string

String formats a Flag.

type In

type In struct {
	Field  string
	Values []Value
	Pos    int
}

In is field in [values].

func (In) String

func (n In) String() string

String formats an In.

type Node

type Node interface {
	// String formats the node back into filter syntax.
	String() string
}

Node is a parsed filter expression.

func Parse

func Parse(src string) (Node, error)

Parse parses a filter. An empty filter parses to nil, which matches every image.

type Not

type Not struct{ X Node }

Not matches when its operand does not.

func (Not) String

func (n Not) String() string

String formats a Not.

type Or

type Or struct{ L, R Node }

Or matches when either side matches.

func (Or) String

func (n Or) String() string

String formats an Or.

type SyntaxError

type SyntaxError struct {
	Pos int
	Msg string
}

SyntaxError reports a problem at a position in the filter.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

Error formats the error with the 1-based column.

type Value

type Value struct {
	// Quoted is true for string literals.
	Quoted bool
	Text   string
	Pos    int
}

Value is a literal.

func (Value) String

func (v Value) String() string

String formats a Value, quoting strings with the only escapes the lexer reads, \" and \\, so printing and re-parsing gives the same value.

Jump to

Keyboard shortcuts

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