filter

package
v1.219.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolFilter

type BoolFilter struct {
	Field string
	Value *bool // nil = all, true = enabled only, false = disabled only
}

BoolFilter filters by boolean field.

func NewBoolFilter

func NewBoolFilter(field string, value *bool) *BoolFilter

NewBoolFilter creates a filter for boolean field values. Value nil = all, true = only true values, false = only false values.

func (*BoolFilter) Apply

func (f *BoolFilter) Apply(data interface{}) (interface{}, error)

Apply filters data by boolean field value.

type Chain

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

Chain combines multiple filters (AND logic).

func NewChain

func NewChain(filters ...Filter) *Chain

NewChain creates a filter chain that applies filters in sequence (AND logic).

func (*Chain) Apply

func (c *Chain) Apply(data interface{}) (interface{}, error)

Apply applies all filters in sequence.

type ColumnValueFilter

type ColumnValueFilter struct {
	Column string
	Value  string
}

ColumnValueFilter filters rows by column value.

func NewColumnFilter

func NewColumnFilter(column, value string) *ColumnValueFilter

NewColumnFilter creates a filter for exact column value matching.

func (*ColumnValueFilter) Apply

func (f *ColumnValueFilter) Apply(data interface{}) (interface{}, error)

Apply filters data by exact column value match.

type Filter

type Filter interface {
	Apply(data interface{}) (interface{}, error)
}

Filter interface for composability.

type GlobFilter

type GlobFilter struct {
	Field   string
	Pattern string
}

GlobFilter matches patterns (e.g., "plat-*-dev").

func NewGlobFilter

func NewGlobFilter(field, pattern string) (*GlobFilter, error)

NewGlobFilter creates a filter that matches field values against glob pattern.

func (*GlobFilter) Apply

func (f *GlobFilter) Apply(data interface{}) (interface{}, error)

Apply filters data by glob pattern matching.

type YQPredicateFilter added in v1.219.0

type YQPredicateFilter struct {
	Expr        string
	AtmosConfig *schema.AtmosConfiguration
}

YQPredicateFilter keeps rows where the YQ expression evaluates to a truthy value. The expression is evaluated once per row against the row's own map (so users write paths like `.vars.region`, not `.<stack>.vars.region`).

Truthy semantics mirror YAML/JSON intuition rather than yq's internal boolean operators: `true` is truthy; `false`, `nil`, and empty strings/maps/slices are falsy; non-empty scalars/maps/slices are truthy.

Errors evaluating the expression against a single row are propagated up so the user sees an invalid-expression diagnostic instead of a silent empty result — yq syntax errors surface on the first row.

func NewYQPredicateFilter added in v1.219.0

func NewYQPredicateFilter(expr string, atmosConfig *schema.AtmosConfiguration) (*YQPredicateFilter, error)

NewYQPredicateFilter creates a filter that keeps rows for which Expr is truthy. Returns an error if Expr is empty.

func (*YQPredicateFilter) Apply added in v1.219.0

func (f *YQPredicateFilter) Apply(data interface{}) (interface{}, error)

Apply evaluates the predicate against each row and returns the matching subset.

type YQProjector added in v1.219.0

type YQProjector struct {
	Expr        string
	AtmosConfig *schema.AtmosConfiguration
}

YQProjector replaces each row with the YQ expression result. Used to wire `--query` on commands like `atmos list instances`.

When the expression returns a map, that map becomes the new row (its keys are addressable as column templates). When it returns a scalar, the row is rewritten to a single "value" column. When the expression returns nil for a row, that row is dropped.

func NewYQProjector added in v1.219.0

func NewYQProjector(expr string, atmosConfig *schema.AtmosConfiguration) (*YQProjector, error)

NewYQProjector creates a projector that rewrites each row using Expr. Returns an error if Expr is empty.

func (*YQProjector) Apply added in v1.219.0

func (p *YQProjector) Apply(data interface{}) (interface{}, error)

Apply runs the projector over each row of data.

Jump to

Keyboard shortcuts

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