Documentation
¶
Overview ¶
Package extquery parses Steadybit's target query language — the language used for environment scopes, experiment blast radii, action target selections and advice assessment queries, e.g.
k8s.namespace="prod" AND NOT k8s.label.tier="canary"
It is generated from the same ANTLR grammar the platform uses, so a query accepted here is accepted there. See grammar/ and generate.sh.
Today the package only offers syntax validation. Extensions embed query strings in their action and advice definitions, where a malformed query is currently only discovered by the platform at registration time — against an already-released artifact. Validate lets an extension catch that in its own tests instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate reports whether query is syntactically valid, returning a *ParseError if it is not.
An empty query is valid and means "match everything", consistent with the platform.
Variable ({{key}}) and template-placeholder ([[key]]) markers are rejected, quoted or not: the platform resolves them against experiment and environment state that an extension has no access to, so a query shipped inside an extension can never legitimately contain one.
Only syntax is checked. Whether the referenced attributes exist, or whether the query selects anything, is not knowable here.
func ValidateAll ¶
ValidateAll validates every query and joins the failures, so a caller checking a whole definition reports all of its bad queries at once rather than one per run.
Types ¶
type Attributes ¶
Attributes is the view a Predicate needs of the thing it matches: a multi-valued attribute map. Values returns the values for a key, or nil when the attribute is absent — the two are treated the same by every operator.
Kits adapt their own types to this. extension-kit deliberately does not import discovery-kit (the dependency runs the other way), so a Target adapter belongs there, not here.
type AttributesFunc ¶
AttributesFunc adapts a lookup function, for callers that resolve attributes lazily or need to inject synthetic keys (e.g. target type or label) without copying the map.
func (AttributesFunc) Values ¶
func (f AttributesFunc) Values(key string) []string
type MapAttributes ¶
MapAttributes adapts a plain attribute map, which is the shape discovery data already has.
func (MapAttributes) Values ¶
func (m MapAttributes) Values(key string) []string
type ParseError ¶
ParseError describes why a query could not be parsed. Line is 1-based and Column is 0-based, matching what ANTLR reports and what the platform surfaces in its own validation messages.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Predicate ¶
type Predicate interface {
Matches(a Attributes) bool
String() string
}
Predicate is a parsed query, ready to match. Predicates are immutable and safe for concurrent use, so parse once at start up and reuse per target.
func MustParse ¶
MustParse is Parse for queries that are compile-time constants, panicking on a bad one. Use it only for literals in package-level variables, never for anything derived from configuration.
func Parse ¶
Parse compiles a query into a Predicate.
The accepted syntax is exactly what Validate accepts, and the same restrictions apply — see its documentation for empty queries and for why platform markers are rejected.
Parsing is the expensive part; matching is not. Parse once at start up and reuse the Predicate for every target.