ast

package
v0.0.0-...-b2113b7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FluentBitSpecialFields

func FluentBitSpecialFields() map[string]string

func LuaQuote

func LuaQuote(in string) string

func ParseTextOrString

func ParseTextOrString(a Attrib) (string, error)

func UnquoteString

func UnquoteString(in string) (string, error)

UnquoteString replaces all escape sequences with their respective characters that they represent.

It assumes the leading and trailing double-quotes have been removed.

Escape sequences are replaced if and only if they are defined in our grammar: confgenerator/filter/internal/filter.bnf. An error is returned if an unrecognized escape sequence is encountered.

This is a compatibility layer to maintain parity with Cloud Logging query strings. strconv.Unquote cannot be used here because it follows escape rules for Go strings, and Cloud Logging strings are not Go strings.

func UnquoteTextOrString

func UnquoteTextOrString(in string) (string, error)

UnquoteTextOrString returns text literals as-is and unquotes string literals.

Types

type Attrib

type Attrib interface{}

type Conjunction

type Conjunction []Expression

Conjunction represents an AND expression

func NewConjunction

func NewConjunction(a Attrib) (Conjunction, error)

func (Conjunction) Append

func (c Conjunction) Append(a Attrib) (Conjunction, error)

func (Conjunction) FluentConfig

func (c Conjunction) FluentConfig(tag, key string) ([]fluentbit.Component, string)

func (Conjunction) OTTLExpression

func (c Conjunction) OTTLExpression() (ottl.Value, error)

func (Conjunction) Simplify

func (c Conjunction) Simplify() Expression

func (Conjunction) String

func (c Conjunction) String() string

type Disjunction

type Disjunction []Expression

Disjunction represents an OR expression

func NewDisjunction

func NewDisjunction(a Attrib) (Disjunction, error)

func (Disjunction) Append

func (d Disjunction) Append(a Attrib) (Disjunction, error)

func (Disjunction) FluentConfig

func (d Disjunction) FluentConfig(tag, key string) ([]fluentbit.Component, string)

func (Disjunction) OTTLExpression

func (d Disjunction) OTTLExpression() (ottl.Value, error)

func (Disjunction) Simplify

func (d Disjunction) Simplify() Expression

func (Disjunction) String

func (d Disjunction) String() string

type Expression

type Expression interface {
	// Simplify returns a logically equivalent Expression.
	Simplify() Expression

	// FluentConfig returns an optional sequence of fluentbit operations and a Lua expression that can be evaluated to determine if the expression matches the record.
	FluentConfig(tag, key string) ([]fluentbit.Component, string)

	// OTTLExpression returns an OTTL value that can be used to evaluate the expression.
	OTTLExpression() (ottl.Value, error)

	fmt.Stringer
}

func Simplify

func Simplify(a Attrib) (Expression, error)

type Negation

type Negation struct {
	Expression
}

func (Negation) FluentConfig

func (n Negation) FluentConfig(tag, key string) ([]fluentbit.Component, string)

func (Negation) OTTLExpression

func (n Negation) OTTLExpression() (ottl.Value, error)

func (Negation) Simplify

func (n Negation) Simplify() Expression

func (Negation) String

func (n Negation) String() string

type Restriction

type Restriction struct {
	Operator string
	// LHS contains the field being matched
	LHS Target
	// RHS contains the string to match against; for regexes, this is a raw string including escape sequences (but always without double quotes).
	RHS string
}

func NewRestriction

func NewRestriction(lhs, operator, rhs Attrib) (*Restriction, error)

func (Restriction) FluentConfig

func (r Restriction) FluentConfig(tag, key string) ([]fluentbit.Component, string)

func (Restriction) OTTLExpression

func (r Restriction) OTTLExpression() (ottl.Value, error)

func (Restriction) Simplify

func (r Restriction) Simplify() Expression

func (Restriction) String

func (r Restriction) String() string

type Target

type Target []string

Target represents member from the filter BNF, and represents either a value or a dotted field path. Each element of the slice is not yet unescaped (if needed).

func (Target) Equals

func (m Target) Equals(m2 Target) bool

Equals checks if two valid targets are equal. Invalid targets are never equal.

func (Target) LuaAccessor

func (m Target) LuaAccessor(write bool) (string, error)

LuaAccessor returns the value of the target (with write=false) or a function that takes one argument to set the target (with write=true).

func (Target) OTTLAccessor

func (m Target) OTTLAccessor() (ottl.LValue, error)

OTTLAccessor returns a string that can be used to refer to the field in OTTL

func (Target) RecordAccessor

func (m Target) RecordAccessor() (string, error)

RecordAccessor returns a string that can be used as a key in a FluentBit config

func (Target) String

func (m Target) String() string

String formats a target as a valid expression

func (Target) Unquote

func (m Target) Unquote() ([]string, error)

Jump to

Keyboard shortcuts

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