Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diagnostic ¶
type Diagnostic struct {
// contains filtered or unexported fields
}
Diagnostic is the detailed message from linter plugin from its rules.
func NewDiagnostic ¶
func NewDiagnostic( level DiagnosticLevel, position parser.PositionRange, message string, ) Diagnostic
NewDiagnostic creates a new diagnostic.
type DiagnosticLevel ¶
type DiagnosticLevel uint
DiagnosticLevel represents the level of a diagnostic.
const ( // DiagnosticLevelInfo represents the "information" level. DiagnosticLevelInfo DiagnosticLevel = iota // DiagnosticLevelWarning represents the "warning" level. DiagnosticLevelWarning // DiagnosticLevelError represents the "error" level. DiagnosticLevelError )
func (DiagnosticLevel) String ¶
func (d DiagnosticLevel) String() string
String implements fmt.Stringer
type Diagnostics ¶
type Diagnostics struct {
// contains filtered or unexported fields
}
Diagnostics holds the set of the linter diagnostic.
func (*Diagnostics) Add ¶
func (ds *Diagnostics) Add(d Diagnostic)
Add appends the given diagnostic to the set.
type PromQLinter ¶
type PromQLinter struct {
// contains filtered or unexported fields
}
PromQLinter is the actual PromQL linter. users can configure this struct for controlling the behaviors of the linter.
func (*PromQLinter) Execute ¶
func (pq *PromQLinter) Execute( rawExpr string, filter DiagnosticLevel, ) (bool, error)
Execute starts the lint process. the rawExpr parameter is a PromQL expression. filter determines whether the reported diagnostics from plugin(s) are ignored.
type PromQLinterOption ¶
type PromQLinterOption func(*PromQLinter)
PromQLinterOption enables the initialization of the PromQLinter by FOP(Functional-Options-Pattern)
func WithOutStream ¶
func WithOutStream(out io.Writer) PromQLinterOption
WithOutStream sets the output stream to the linter.
func WithPlugin ¶
func WithPlugin(plugin PromQLinterPlugin) PromQLinterOption
WithPlugins appends the given plugin to the linter plugins.
func WithPlugins ¶
func WithPlugins(plugins ...PromQLinterPlugin) PromQLinterOption
WithPlugins sets the set of the linter plugin to the linter. Note that this function should be called before WithPlugin(). Because this function updates the plugin set entirely.
type PromQLinterPlugin ¶
type PromQLinterPlugin interface { // Name represents the name of the plugin. // the name is used in the reporting message from the linter. Name() string // Execute lints the PromQL expression. Execute(expr parser.Expr) (*Diagnostics, error) }
PromQLinterPlugin is an interface that all linter plugin must implement.