Help us shape the future of Go! Take the 2026 Go Developer Survey

filter

package
v1.233.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 8 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 LabelFilter added in v1.223.0

type LabelFilter struct {
	Field  string
	Labels map[string]string
}

LabelFilter filters rows whose Field (map[string]string) matches every key=value pair in Labels (AND).

func NewLabelFilter added in v1.223.0

func NewLabelFilter(field string, filterLabels map[string]string) *LabelFilter

NewLabelFilter creates a filter matching rows whose Field contains every key=value pair in filterLabels. An empty filterLabels matches everything (no filter applied).

func (*LabelFilter) Apply added in v1.223.0

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

Apply filters rows by all-match against the Field's map[string]string value.

type PredicateFilter added in v1.225.0

type PredicateFilter struct {
	// Name identifies the filter in debugging output.
	Name string
	// Predicate reports whether a row is kept. A nil predicate keeps every row.
	Predicate func(map[string]any) bool
}

PredicateFilter keeps rows satisfying an arbitrary predicate. Used for selections computed outside the row data itself (e.g. dependency-closure membership), where no single field comparison can express the filter.

func NewPredicateFilter added in v1.225.0

func NewPredicateFilter(name string, predicate func(map[string]any) bool) *PredicateFilter

NewPredicateFilter creates a filter keeping rows for which predicate is true.

func (*PredicateFilter) Apply added in v1.225.0

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

Apply filters rows by the predicate.

type TagFilter added in v1.223.0

type TagFilter struct {
	Field string
	Tags  []string
}

TagFilter filters rows whose Field ([]string) matches any of Tags (OR).

func NewTagFilter added in v1.223.0

func NewTagFilter(field string, filterTags []string) *TagFilter

NewTagFilter creates a filter matching rows whose Field contains any of filterTags. An empty filterTags matches everything (no filter applied).

func (*TagFilter) Apply added in v1.223.0

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

Apply filters rows by any-match against the Field's []string value.

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