parser

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertingRule

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

func (AlertingRule) Comments

func (ar AlertingRule) Comments() (comments []string)

func (AlertingRule) Lines

func (ar AlertingRule) Lines() (lines []int)

type Comment added in v0.18.0

type Comment struct {
	Key   string
	Value string
}

func GetComments added in v0.32.0

func GetComments(text string, comment ...string) (comments []Comment)

func GetLastComment added in v0.32.0

func GetLastComment(text string, comment ...string) (Comment, bool)

func (Comment) String added in v0.18.0

func (c Comment) String() string

type Content added in v0.30.0

type Content struct {
	Body    []byte
	Ignored bool
}

func ReadContent

func ReadContent(r io.Reader) (out Content, err error)

type FilePosition

type FilePosition struct {
	Lines []int
}

func NewFilePosition

func NewFilePosition(l []int) FilePosition

func (FilePosition) FirstLine

func (fp FilePosition) FirstLine() (line int)

func (FilePosition) LastLine

func (fp FilePosition) LastLine() (line int)

type ParseError

type ParseError struct {
	Fragment string
	Err      error
	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 {
	Key         *YamlNode
	Value       *YamlNode
	SyntaxError error
	Query       *PromQLNode
}

func (PromQLExpr) Lines

func (pqle PromQLExpr) Lines() (lines []int)

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 {
	Record YamlKeyValue
	Expr   PromQLExpr
	Labels *YamlMap
}

func (RecordingRule) Comments

func (rr RecordingRule) Comments() (comments []string)

func (RecordingRule) Lines

func (rr RecordingRule) Lines() (lines []int)

type Result

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

type Rule

type Rule struct {
	AlertingRule  *AlertingRule
	RecordingRule *RecordingRule
	Error         ParseError
}

func (Rule) Expr

func (r Rule) Expr() PromQLExpr

func (Rule) GetComment added in v0.16.0

func (r Rule) GetComment(comment ...string) (s Comment, ok bool)

func (Rule) GetComments added in v0.28.0

func (r Rule) GetComments(key string) (cs []Comment)

func (Rule) HasComment

func (r Rule) HasComment(comment string) bool

func (Rule) IsSame added in v0.27.0

func (r Rule) IsSame(nr Rule) bool

func (Rule) LineRange added in v0.18.0

func (r Rule) LineRange() []int

func (Rule) Lines

func (r Rule) Lines() []int

func (Rule) Name added in v0.40.1

func (r Rule) Name() string

func (Rule) ToYAML added in v0.40.1

func (r Rule) ToYAML() 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 Snooze added in v0.40.0

type Snooze struct {
	Until time.Time
	Text  string
}

func ParseSnooze added in v0.40.0

func ParseSnooze(comment string) *Snooze

type YamlKeyValue

type YamlKeyValue struct {
	Key   *YamlNode
	Value *YamlNode
}

func (YamlKeyValue) Lines

func (ykv YamlKeyValue) Lines() (lines []int)

type YamlMap

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

func (YamlMap) GetValue

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

func (YamlMap) Lines

func (ym YamlMap) Lines() (lines []int)

type YamlNode

type YamlNode struct {
	Position FilePosition
	Value    string
	Comments []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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