Documentation
¶
Overview ¶
Package filter applies filter expressions to api table rows, tree nodes and map rows through the configured Adapter.
Index ¶
- Variables
- func MapRows(rows []map[string]any, expression string) ([]map[string]any, error)
- func SetAdapter(a Adapter)
- func TableRows(rows []api.PrettyDataRow, filterExpr string) ([]api.PrettyDataRow, error)
- func TreeNode(node api.TreeNode, filterExpr string) (api.TreeNode, error)
- func Validate(expression string) error
- type Adapter
- type MapPredicate
- type Predicate
Constants ¶
This section is empty.
Variables ¶
var ErrMissingVariable = errors.New("missing variable")
ErrMissingVariable is wrapped by adapters when a predicate references a variable absent from the evaluated row or node.
var ErrNoAdapter = errors.New("no filter adapter configured: call celfilter.Use() from github.com/flanksource/clicky/api/filter/celfilter or gomplatefilter.Use() from github.com/flanksource/clicky/api/filter/gomplatefilter")
Functions ¶
func SetAdapter ¶ added in v1.21.83
func SetAdapter(a Adapter)
func TableRows ¶
func TableRows(rows []api.PrettyDataRow, filterExpr string) ([]api.PrettyDataRow, error)
TableRows filters table rows using an expression. Field values are injected directly into the expression context (no "row." prefix).
Types ¶
type Adapter ¶ added in v1.21.83
type Adapter interface {
Validate(expression string) error
// Compile prepares expression for variables shaped like sample. A nil value
// in sample declares a variable without a fixed type.
Compile(expression string, sample map[string]any) (Predicate, error)
}
Adapter is the expression engine behind TableRows, TreeNode and MapRows. The core package ships none: applications opt in with celfilter.Use() or gomplatefilter.Use() so library consumers don't compile an engine they never call.
type MapPredicate ¶ added in v1.21.81
type MapPredicate struct {
// contains filtered or unexported fields
}
func CompileMapPredicate ¶ added in v1.21.81
func CompileMapPredicate(keys []string, expression string) (*MapPredicate, error)
CompileMapPredicate compiles expression for map rows with the given keys. Values are untyped; "row" holds every column so keys with spaces stay addressable.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package celfilter is the CEL engine for github.com/flanksource/clicky/api/filter.
|
Package celfilter is the CEL engine for github.com/flanksource/clicky/api/filter. |
|
Package gomplatefilter adds the flanksource/gomplate CEL function set to filter expressions.
|
Package gomplatefilter adds the flanksource/gomplate CEL function set to filter expressions. |