Documentation ¶
Overview ¶
Package ast declares the types used to represent syntax trees for Logstash configurations.
Index ¶
- Constants
- Variables
- func IsNotFoundError(e error) bool
- func NewNotFoundError(err error) error
- func NotFoundErrorf(format string, a ...interface{}) error
- type ArrayAttribute
- type Attribute
- type BoolExpression
- type BooleanOperator
- type Branch
- type BranchOrPlugin
- type Comment
- type CommentBlock
- type Commentable
- type CompareExpression
- type CompareOperator
- type Condition
- type ConditionExpression
- type Config
- type ElseBlock
- type ElseIfBlock
- type Expression
- type HashAttribute
- type HashEntry
- type HashEntryKey
- type IfBlock
- type InExpression
- type NegativeConditionExpression
- type NegativeSelectorExpression
- type Node
- type NotFounder
- type NotInExpression
- type NumberAttribute
- type Plugin
- type PluginAttribute
- type PluginSection
- type PluginType
- type Pos
- type Regexp
- type RegexpExpression
- type RegexpOperator
- type Rvalue
- type RvalueExpression
- type Selector
- type SelectorElement
- type StringAttribute
- func (sa StringAttribute) CommentBlock() string
- func (sa StringAttribute) Name() string
- func (sa StringAttribute) Pos() Pos
- func (sa StringAttribute) String() string
- func (sa StringAttribute) StringAttributeType() StringAttributeType
- func (sa StringAttribute) Value() string
- func (sa StringAttribute) ValueString() string
- type StringAttributeType
- type StringOrRegexp
- type Whitespace
Constants ¶
const ( // Input type plugin Input = iota + 1 // Filter type plugin Filter // Output type plugin Output )
const ( // DoubleQuoted string attribute type DoubleQuoted = iota + 1 // SingleQuoted string attribute type SingleQuoted // Bareword string attribute type Bareword )
const ( // Equal defines the equal operator (==) Equal = iota + 1 // NotEqual defines the not equal operator (!=) NotEqual // LessOrEqual defines the less or equal operator (<=) LessOrEqual // GreaterOrEqual defines the greater or equal operator (>=) GreaterOrEqual // LessThan defines the less than operator (<) LessThan // GreaterThan defines the greater than operator (>) GreaterThan )
const ( // RegexpMatch is the regular expression match operator (=~) RegexpMatch = iota + 1 // RegexpNotMatch is the regular expression not match operator (!~) RegexpNotMatch )
const ( // NoOperator is used for the first expression, which is not chained by a boolean operator NoOperator = iota + 1 // And is the and boolean operator And // Or is the or boolean operator Or // Xor is the xor boolean operator Xor // Nand is the nand boolean operator Nand )
const Undefined = 0
Undefined is a placeholder for all undefined values in all available types in this package.
Variables ¶
var InvalidPos = Pos{Offset: -1}
Functions ¶
func IsNotFoundError ¶ added in v0.4.0
IsNotFoundError returns true, if the provided error implements the NotFound interface.
func NewNotFoundError ¶ added in v0.4.0
NewNotFoundError wraps an error as a not found error.
func NotFoundErrorf ¶ added in v0.4.0
NotFoundErrorf formats according to a format specifier and returns the string as a value that satisfies NotFounder.
Types ¶
type ArrayAttribute ¶
type ArrayAttribute struct { Start Pos Attributes []Attribute Comment CommentBlock // contains filtered or unexported fields }
A ArrayAttribute node represents a plugin attribute of type array.
func NewArrayAttribute ¶
func NewArrayAttribute(name string, value ...Attribute) ArrayAttribute
NewArrayAttribute creates a new array attribute.
func (ArrayAttribute) CommentBlock ¶ added in v0.4.1
func (aa ArrayAttribute) CommentBlock() string
CommentBlock returns the comment of the node.
func (ArrayAttribute) Name ¶ added in v0.2.0
func (aa ArrayAttribute) Name() string
Name returns the name of the attribute.
func (ArrayAttribute) Pos ¶ added in v0.5.0
func (aa ArrayAttribute) Pos() Pos
func (ArrayAttribute) String ¶
func (aa ArrayAttribute) String() string
String returns a string representation of a array attribute.
func (ArrayAttribute) Value ¶
func (aa ArrayAttribute) Value() []Attribute
Value returns the value of the node.
func (ArrayAttribute) ValueString ¶
func (aa ArrayAttribute) ValueString() string
ValueString returns the value of the node as a string representation.
type Attribute ¶
type Attribute interface { Name() string String() string ValueString() string CommentBlock() string Pos() Pos // contains filtered or unexported methods }
Attribute interface combines Logstash plugin attribute types.
type BoolExpression ¶
type BoolExpression struct { Start Pos // contains filtered or unexported fields }
A BoolExpression node represents a boolean operator.
func (*BoolExpression) BoolOperator ¶
func (be *BoolExpression) BoolOperator() BooleanOperator
BoolOperator returns the boolean operator of the node.
func (BoolExpression) Pos ¶ added in v0.5.0
func (be BoolExpression) Pos() Pos
func (*BoolExpression) SetBoolOperator ¶
func (be *BoolExpression) SetBoolOperator(bo BooleanOperator)
SetBoolOperator sets the boolean operator for the node.
func (BoolExpression) String ¶
func (be BoolExpression) String() string
String returns a string representation of a boolean expression.
type BooleanOperator ¶
A BooleanOperator represents a boolean operator.
func (BooleanOperator) Pos ¶ added in v0.5.0
func (bo BooleanOperator) Pos() Pos
func (BooleanOperator) String ¶
func (be BooleanOperator) String() string
String returns a string representation of a boolean operator.
type Branch ¶
type Branch struct { IfBlock IfBlock ElseIfBlock []ElseIfBlock ElseBlock ElseBlock }
A Branch node represents a conditional branch within a Logstash configuration.
type BranchOrPlugin ¶
type BranchOrPlugin interface { Pos() Pos // contains filtered or unexported methods }
BranchOrPlugin interface combines Logstash configuration conditional branches and plugins.
type Comment ¶ added in v0.4.1
func NewComment ¶ added in v0.4.1
type CommentBlock ¶ added in v0.4.1
type CommentBlock []Comment
func NewCommentBlock ¶ added in v0.4.1
func NewCommentBlock(comments ...Comment) CommentBlock
func (CommentBlock) String ¶ added in v0.4.1
func (cb CommentBlock) String() string
type Commentable ¶ added in v0.4.1
type Commentable interface {
SetComment(cb CommentBlock)
}
A Commentable node is an ast node, which accepts comments.
type CompareExpression ¶
type CompareExpression struct { Start Pos *BoolExpression LValue Rvalue CompareOperator CompareOperator RValue Rvalue }
A CompareExpression node represents a expression, which compares lvalue and rvalue based on the comparison operator.
func NewCompareExpression ¶
func NewCompareExpression(boolOperator BooleanOperator, lvalue Rvalue, compareOperator CompareOperator, rvalue Rvalue) CompareExpression
NewCompareExpression creates a new compare expression.
func (CompareExpression) Pos ¶ added in v0.5.0
func (ce CompareExpression) Pos() Pos
func (CompareExpression) String ¶
func (ce CompareExpression) String() string
String returns a string representation of a compare expression.
type CompareOperator ¶
A CompareOperator represents the comparison operator, used to compare two values.
func (CompareOperator) Pos ¶ added in v0.5.0
func (co CompareOperator) Pos() Pos
func (CompareOperator) String ¶
func (co CompareOperator) String() string
String returns a string representation of a compare operator.
type Condition ¶
type Condition struct {
Expression []Expression
}
A Condition node represents a condition used by if- or else-if-blocks.
func NewCondition ¶
func NewCondition(expression ...Expression) Condition
NewCondition creates a new condition.
type ConditionExpression ¶
type ConditionExpression struct { Start Pos *BoolExpression Condition Condition }
A ConditionExpression node represents an Expression, which is enclosed in parentheses.
func NewConditionExpression ¶
func NewConditionExpression(boolOperator BooleanOperator, condition Condition) ConditionExpression
NewConditionExpression creates a new condition expression.
func (ConditionExpression) Pos ¶ added in v0.5.0
func (ce ConditionExpression) Pos() Pos
func (ConditionExpression) String ¶
func (ce ConditionExpression) String() string
String returns a string representation of a condition expression.
type Config ¶
type Config struct { Input []PluginSection Filter []PluginSection Output []PluginSection Warnings []string }
A Config node represents the root node of a Logstash configuration.
func NewConfig ¶
func NewConfig(input, filter, output []PluginSection) Config
NewConfig creates a new Logstash config.
type ElseBlock ¶
type ElseBlock struct { Start Pos Block []BranchOrPlugin Comment CommentBlock }
A ElseBlock node represents a else-block of a Branch.
func NewElseBlock ¶
func NewElseBlock(block ...BranchOrPlugin) ElseBlock
NewElseBlock creates a new else-block
type ElseIfBlock ¶
type ElseIfBlock struct { Start Pos Condition Condition Block []BranchOrPlugin Comment CommentBlock }
A ElseIfBlock node represents an else-if-block of a Branch.
func NewElseIfBlock ¶
func NewElseIfBlock(condition Condition, block ...BranchOrPlugin) ElseIfBlock
NewElseIfBlock creates a new else-if-block of a Branch.
func (ElseIfBlock) Pos ¶ added in v0.5.0
func (eib ElseIfBlock) Pos() Pos
func (ElseIfBlock) String ¶
func (eib ElseIfBlock) String() string
String returns a string representation of an else if block.
type Expression ¶
type Expression interface { Pos() Pos BoolOperator() BooleanOperator SetBoolOperator(BooleanOperator) // contains filtered or unexported methods }
An Expression node defines an expression. An Expression is chainable with a preceding Expression by the the boolean operator.
type HashAttribute ¶
type HashAttribute struct { Start Pos Entries []HashEntry Comment CommentBlock // contains filtered or unexported fields }
A HashAttribute node represents a plugin attribute of type hash.
func NewHashAttribute ¶
func NewHashAttribute(name string, entries ...HashEntry) HashAttribute
NewHashAttribute creates a new hash attribute.
func (HashAttribute) CommentBlock ¶ added in v0.4.1
func (ha HashAttribute) CommentBlock() string
CommentBlock returns the comment of the node.
func (HashAttribute) Name ¶ added in v0.2.0
func (ha HashAttribute) Name() string
Name returns the name of the attribute.
func (HashAttribute) Pos ¶ added in v0.5.0
func (ha HashAttribute) Pos() Pos
func (HashAttribute) String ¶
func (ha HashAttribute) String() string
String returns a string representation of a hash attribute.
func (HashAttribute) Value ¶
func (ha HashAttribute) Value() []HashEntry
Value returns the value of the node.
func (HashAttribute) ValueString ¶
func (ha HashAttribute) ValueString() string
ValueString returns the value of the node as a string representation.
type HashEntry ¶
type HashEntry struct { Start Pos Key HashEntryKey Value Attribute Comment CommentBlock }
A HashEntry node defines a hash entry within a hash attribute.
func NewHashEntry ¶
func NewHashEntry(name HashEntryKey, value Attribute) HashEntry
NewHashEntry creates a new hash entry for a hash attribute.
func (HashEntry) ValueString ¶
ValueString returns the value of the node as a string representation.
type HashEntryKey ¶ added in v0.4.5
type IfBlock ¶
type IfBlock struct { Start Pos Condition Condition Block []BranchOrPlugin Comment CommentBlock }
A IfBlock node represents an if-block of a Branch.
func NewIfBlock ¶
func NewIfBlock(condition Condition, block ...BranchOrPlugin) IfBlock
NewIfBlock creates a new if-block.
type InExpression ¶
type InExpression struct { Start Pos *BoolExpression LValue Rvalue RValue Rvalue }
An InExpression node represents an in expression.
func NewInExpression ¶
func NewInExpression(boolOperator BooleanOperator, lvalue Rvalue, rvalue Rvalue) InExpression
NewInExpression creates a new in expression.
func (InExpression) Pos ¶ added in v0.5.0
func (ie InExpression) Pos() Pos
func (InExpression) String ¶
func (ie InExpression) String() string
String returns a string representation of an in expression.
type NegativeConditionExpression ¶
type NegativeConditionExpression struct { Start Pos *BoolExpression Condition Condition }
A NegativeConditionExpression node represents an Expression within parentheses, which is negated.
func NewNegativeConditionExpression ¶
func NewNegativeConditionExpression(boolOperator BooleanOperator, condition Condition) NegativeConditionExpression
NewNegativeConditionExpression creates a new negative condition expression.
func (NegativeConditionExpression) Pos ¶ added in v0.5.0
func (nc NegativeConditionExpression) Pos() Pos
func (NegativeConditionExpression) String ¶
func (nc NegativeConditionExpression) String() string
String returns a string representation of a negative condition expression.
type NegativeSelectorExpression ¶
type NegativeSelectorExpression struct { Start Pos *BoolExpression Selector Selector }
A NegativeSelectorExpression node represents a field selector expression, which is negated.
func NewNegativeSelectorExpression ¶
func NewNegativeSelectorExpression(boolOperator BooleanOperator, selector Selector) NegativeSelectorExpression
NewNegativeSelectorExpression creates a new negative selector expression.
func (NegativeSelectorExpression) Pos ¶ added in v0.5.0
func (ns NegativeSelectorExpression) Pos() Pos
func (NegativeSelectorExpression) String ¶
func (ns NegativeSelectorExpression) String() string
String returns a string representation of a negative selector expression.
type NotFounder ¶ added in v0.4.0
type NotFounder interface { Error() string NotFound() }
NotFounder interface is implemented by errors, that indicate that a record is not found.
type NotInExpression ¶
type NotInExpression struct { Start Pos *BoolExpression RValue Rvalue LValue Rvalue }
A NotInExpression node defines a not in expression.
func NewNotInExpression ¶
func NewNotInExpression(boolOperator BooleanOperator, lvalue Rvalue, rvalue Rvalue) NotInExpression
NewNotInExpression creates a new not in expression.
func (NotInExpression) Pos ¶ added in v0.5.0
func (nie NotInExpression) Pos() Pos
func (NotInExpression) String ¶
func (nie NotInExpression) String() string
String returns a string representation of a not in expression.
type NumberAttribute ¶
type NumberAttribute struct { Start Pos Comment CommentBlock // contains filtered or unexported fields }
A NumberAttribute node represents a plugin attribute of type number.
func NewNumberAttribute ¶
func NewNumberAttribute(name string, value float64) NumberAttribute
NewNumberAttribute creates a new number attribute.
func (NumberAttribute) CommentBlock ¶ added in v0.4.1
func (na NumberAttribute) CommentBlock() string
CommentBlock returns the comment of the node.
func (NumberAttribute) Name ¶ added in v0.2.0
func (na NumberAttribute) Name() string
Name returns the name of the attribute.
func (NumberAttribute) Pos ¶ added in v0.5.0
func (na NumberAttribute) Pos() Pos
func (NumberAttribute) String ¶
func (na NumberAttribute) String() string
String returns a string representation of a number attribute.
func (NumberAttribute) Value ¶
func (na NumberAttribute) Value() float64
Value returns the value of the node.
func (NumberAttribute) ValueString ¶
func (na NumberAttribute) ValueString() string
ValueString returns the value of the node as a string representation.
type Plugin ¶
type Plugin struct { Start Pos Attributes []Attribute Comment CommentBlock // contains filtered or unexported fields }
A Plugin node represents a Logstash plugin.
func (Plugin) ID ¶ added in v0.4.0
ID returns the id of a Logstash plugin. The id attribute is one of the common options, that is optionally available on every Logstash plugin. In generall, it is highly recommended for a Logstash plugin to have an id. If the ID attribute is not present, an error is returned, who implements the NotFounder interface.
type PluginAttribute ¶
type PluginAttribute struct { Start Pos Comment CommentBlock // contains filtered or unexported fields }
A PluginAttribute node represents a plugin attribute of type plugin.
func NewPluginAttribute ¶
func NewPluginAttribute(name string, value Plugin) PluginAttribute
NewPluginAttribute creates a new plugin attribute.
func (PluginAttribute) CommentBlock ¶ added in v0.4.1
func (pa PluginAttribute) CommentBlock() string
CommentBlock returns the comment of the node.
func (PluginAttribute) Name ¶ added in v0.2.0
func (pa PluginAttribute) Name() string
Name returns the name of the attribute.
func (PluginAttribute) Pos ¶ added in v0.5.0
func (pa PluginAttribute) Pos() Pos
func (PluginAttribute) String ¶
func (pa PluginAttribute) String() string
String returns a string representation of a plugin attribute.
func (PluginAttribute) ValueString ¶
func (pa PluginAttribute) ValueString() string
ValueString returns the value of the node as a string representation.
type PluginSection ¶
type PluginSection struct { Start Pos PluginType PluginType BranchOrPlugins []BranchOrPlugin CommentBlock CommentBlock }
A PluginSection node defines the configuration section with branches or plugins.
func NewPluginSection ¶
func NewPluginSection(pt PluginType, bop ...BranchOrPlugin) PluginSection
NewPluginSection creates a new plugin section.
func NewPluginSections ¶
func NewPluginSections(pt PluginType, bop ...BranchOrPlugin) []PluginSection
NewPluginSections creates an array of plugin sections.
func (PluginSection) Pos ¶ added in v0.5.0
func (ps PluginSection) Pos() Pos
func (PluginSection) String ¶
func (ps PluginSection) String() string
String returns a string representation of a plugin section.
type PluginType ¶
type PluginType int
PluginType defines the type of a Logstash plugin, which is one of: Input, Filter or Output.
func (PluginType) String ¶
func (pt PluginType) String() string
String returns a string representation of a plugin type.
type Regexp ¶
A Regexp node represents a regular expression.
func (Regexp) ValueString ¶
ValueString returns the value of the node as a string representation.
type RegexpExpression ¶
type RegexpExpression struct { Start Pos *BoolExpression LValue Rvalue RegexpOperator RegexpOperator RValue StringOrRegexp }
A RegexpExpression node defines a regular expression node.
func NewRegexpExpression ¶
func NewRegexpExpression(boolOperator BooleanOperator, lvalue Rvalue, regexpOperator RegexpOperator, rvalue StringOrRegexp) RegexpExpression
NewRegexpExpression creates a new regexp (regular expression) expression.
func (RegexpExpression) Pos ¶ added in v0.5.0
func (re RegexpExpression) Pos() Pos
func (RegexpExpression) String ¶
func (re RegexpExpression) String() string
String returns a string representation of a regexp expression.
type RegexpOperator ¶
A RegexpOperator is an operator, used to compare a regular expression with an other value.
func (RegexpOperator) Pos ¶ added in v0.5.0
func (ro RegexpOperator) Pos() Pos
func (RegexpOperator) String ¶
func (ro RegexpOperator) String() string
String returns a string representation of a regexp operator.
type Rvalue ¶
type Rvalue interface { Pos() Pos String() string ValueString() string // contains filtered or unexported methods }
A Rvalue node represents an right (or in some cases also an left) side value of an expression.
type RvalueExpression ¶
type RvalueExpression struct { Start Pos *BoolExpression RValue Rvalue }
A RvalueExpression node defines an expression consisting only of a Rvalue.
func NewRvalueExpression ¶
func NewRvalueExpression(boolOperator BooleanOperator, rvalue Rvalue) RvalueExpression
NewRvalueExpression creates a new rvalue expression.
func (RvalueExpression) Pos ¶ added in v0.5.0
func (re RvalueExpression) Pos() Pos
func (RvalueExpression) String ¶
func (re RvalueExpression) String() string
String returns a string representation of a rvalue expression.
type Selector ¶
type Selector struct { Start Pos Elements []SelectorElement }
A Selector node represents a field selector.
func NewSelector ¶
func NewSelector(elements []SelectorElement) Selector
NewSelector creates a new Selector.
func NewSelectorFromNames ¶
NewSelectorFromNames creates a new Selector form a slice of field names.
func (Selector) ValueString ¶
ValueString returns the value of the node as a string representation.
type SelectorElement ¶
type SelectorElement struct { Start Pos // contains filtered or unexported fields }
A SelectorElement node defines a selector element.
func NewSelectorElement ¶
func NewSelectorElement(name string) SelectorElement
NewSelectorElement creates a new selector element.
func (SelectorElement) Pos ¶ added in v0.5.0
func (se SelectorElement) Pos() Pos
func (SelectorElement) String ¶
func (se SelectorElement) String() string
String returns a string representation of a selector element.
type StringAttribute ¶
type StringAttribute struct { Start Pos Comment CommentBlock // contains filtered or unexported fields }
StringAttribute is a plugin attribute of type string.
func NewStringAttribute ¶
func NewStringAttribute(name, value string, sat StringAttributeType) StringAttribute
NewStringAttribute creates a new plugin attribute of type string.
func (StringAttribute) CommentBlock ¶ added in v0.4.1
func (sa StringAttribute) CommentBlock() string
CommentBlock returns the comment of the node.
func (StringAttribute) Name ¶ added in v0.2.0
func (sa StringAttribute) Name() string
Name returns the name of the attribute.
func (StringAttribute) Pos ¶ added in v0.5.0
func (sa StringAttribute) Pos() Pos
func (StringAttribute) String ¶
func (sa StringAttribute) String() string
String returns a string representation of a string attribute.
func (StringAttribute) StringAttributeType ¶
func (sa StringAttribute) StringAttributeType() StringAttributeType
StringAttributeType returns the string attribute type.
func (StringAttribute) Value ¶
func (sa StringAttribute) Value() string
Value returns the value of the node.
func (StringAttribute) ValueString ¶
func (sa StringAttribute) ValueString() string
ValueString returns the value of the node as a string representation.
type StringAttributeType ¶
type StringAttributeType int
StringAttributeType defines the string format type of a string attribute.
func (StringAttributeType) String ¶
func (sat StringAttributeType) String() string
String returns a string representation of a string attribute type.
type StringOrRegexp ¶
type StringOrRegexp interface { Pos() Pos String() string ValueString() string // contains filtered or unexported methods }
A StringOrRegexp node is a string attribute node or a regexp node.
type Whitespace ¶ added in v0.4.1
type Whitespace struct{}