parser

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRuleCommentOnFile = errors.New("this comment is only valid when attached to a rule")

Functions

This section is empty.

Types

type AlertingRule

type AlertingRule struct {
	Expr          PromQLExpr
	For           *YamlNode
	KeepFiringFor *YamlNode
	Labels        *YamlMap
	Annotations   *YamlMap
	Alert         YamlNode
}

func (*AlertingRule) IsIdentical added in v0.50.0

func (ar *AlertingRule) IsIdentical(b *AlertingRule) bool

type Content added in v0.30.0

type Content struct {
	Body       []byte
	TotalLines int
	IgnoreLine int
	Ignored    bool
}

func ReadContent

func ReadContent(r io.Reader) (out Content, fileComments []comments.Comment, err error)

type LineRange added in v0.54.0

type LineRange struct {
	First int
	Last  int
}

func (LineRange) Expand added in v0.54.0

func (lr LineRange) Expand() []int

func (LineRange) String added in v0.54.0

func (lr LineRange) String() string

type ParseError

type ParseError struct {
	Err      error
	Fragment string
	Line     int
}

type Parser

type Parser struct{}

func NewParser

func NewParser() Parser

func (Parser) Parse

func (p Parser) Parse(content []byte) (rules []Rule, err error)

type PromQLError

type PromQLError struct {
	Err error
	// contains filtered or unexported fields
}

func (PromQLError) Error

func (pqle PromQLError) Error() string

func (PromQLError) Node

func (pqle PromQLError) Node() *PromQLNode

func (*PromQLError) Unwrap

func (pqle *PromQLError) Unwrap() error

type PromQLExpr

type PromQLExpr struct {
	Value       *YamlNode
	SyntaxError error
	Query       *PromQLNode
}

func (PromQLExpr) IsIdentical added in v0.50.0

func (pqle PromQLExpr) IsIdentical(b PromQLExpr) bool

type PromQLNode

type PromQLNode struct {
	Expr     string
	Node     promparser.Expr
	Children []*PromQLNode
}

func DecodeExpr added in v0.2.0

func DecodeExpr(expr string) (*PromQLNode, error)

type RecordingRule

type RecordingRule struct {
	Expr   PromQLExpr
	Labels *YamlMap
	Record YamlNode
}

func (*RecordingRule) IsIdentical added in v0.50.0

func (rr *RecordingRule) IsIdentical(b *RecordingRule) bool

type Result

type Result struct {
	Path    string
	Error   error
	Content []byte
	Rules   []Rule
}

type Rule

type Rule struct {
	AlertingRule  *AlertingRule
	RecordingRule *RecordingRule
	Error         ParseError
	Comments      []comments.Comment
	Lines         LineRange
}

func (Rule) Expr

func (r Rule) Expr() PromQLExpr

func (Rule) IsIdentical added in v0.50.0

func (r Rule) IsIdentical(b Rule) bool

func (Rule) IsSame added in v0.27.0

func (r Rule) IsSame(nr Rule) bool

func (Rule) Name added in v0.40.1

func (r Rule) Name() string

func (Rule) Type added in v0.40.1

func (r Rule) Type() RuleType

type RuleType added in v0.40.1

type RuleType string
const (
	AlertingRuleType  RuleType = "alerting"
	RecordingRuleType RuleType = "recording"
	InvalidRuleType   RuleType = "invalid"
)

type YamlKeyValue

type YamlKeyValue struct {
	Key   *YamlNode
	Value *YamlNode
}

type YamlMap

type YamlMap struct {
	Key   *YamlNode
	Items []*YamlKeyValue
	Lines LineRange
}

func (YamlMap) GetValue

func (ym YamlMap) GetValue(key string) *YamlNode

func (*YamlMap) IsIdentical added in v0.50.0

func (ym *YamlMap) IsIdentical(b *YamlMap) bool

type YamlNode

type YamlNode struct {
	Value string
	Lines LineRange
}

func (*YamlNode) IsIdentical added in v0.54.0

func (yn *YamlNode) IsIdentical(b *YamlNode) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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