Documentation
¶
Overview ¶
Package expr provides expression evaluation for pipeline gates.
Index ¶
- func Compile(expression string) error
- func CompileWithContext(expression string, ctx Context) error
- func Evaluate(expression string, ctx Context) (bool, error)
- type ACContext
- type AlertsContext
- type Context
- type ContextBuilder
- func (b *ContextBuilder) Build() Context
- func (b *ContextBuilder) WithAcceptanceCriteria(count, checked int) *ContextBuilder
- func (b *ContextBuilder) WithAlerts(count, critical, warning int) *ContextBuilder
- func (b *ContextBuilder) WithDecisions(total, resolved int) *ContextBuilder
- func (b *ContextBuilder) WithDeploy(stagingStatus string, stagingHealthy bool, prodStatus string, prodHealthy bool) *ContextBuilder
- func (b *ContextBuilder) WithPRStack(exists bool, steps, completed int, allOpened, allApproved bool) *ContextBuilder
- func (b *ContextBuilder) WithPRs(open, approved int, threadsResolved bool) *ContextBuilder
- func (b *ContextBuilder) WithSection(slug string, content string) *ContextBuilder
- func (b *ContextBuilder) WithSections(sections map[string]string) *ContextBuilder
- func (b *ContextBuilder) WithSpec(id, title, status string, labels []string, wordCount int, ...) *ContextBuilder
- type DecisionsContext
- type DeployContext
- type EnvironmentStatus
- type ItemsContext
- type PRStackContext
- type PRsContext
- type SectionContext
- type SpecContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
Compile validates an expression at config load time. Returns an error if the expression is invalid.
func CompileWithContext ¶
CompileWithContext validates an expression with a specific context.
Types ¶
type ACContext ¶
type ACContext struct {
Items ItemsContext `expr:"items"`
}
ACContext contains acceptance criteria statistics.
type AlertsContext ¶
type AlertsContext struct {
Count int `expr:"count"`
Critical int `expr:"critical"`
Warning int `expr:"warning"`
}
AlertsContext contains alert statistics.
type Context ¶
type Context struct {
// Spec contains spec metadata
Spec SpecContext `expr:"spec"`
// Sections contains per-section metadata keyed by slug
Sections map[string]SectionContext `expr:"sections"`
// Decisions contains decision log statistics
Decisions DecisionsContext `expr:"decisions"`
// AcceptanceCriteria contains AC statistics
AcceptanceCriteria ACContext `expr:"acceptance_criteria"`
// PRStack contains PR stack plan statistics
PRStack PRStackContext `expr:"pr_stack"`
// PRs contains pull request statistics
PRs PRsContext `expr:"prs"`
// Deploy contains deployment status
Deploy DeployContext `expr:"deploy"`
// Alerts contains alert statistics
Alerts AlertsContext `expr:"alerts"`
}
Context is the environment available to gate expressions. All fields are exported and accessible in expressions.
func NewContext ¶
func NewContext() Context
NewContext creates a new empty context with initialized maps.
type ContextBuilder ¶
type ContextBuilder struct {
// contains filtered or unexported fields
}
ContextBuilder helps build an expression context from spec data.
func NewContextBuilder ¶
func NewContextBuilder() *ContextBuilder
NewContextBuilder creates a new context builder.
func (*ContextBuilder) Build ¶
func (b *ContextBuilder) Build() Context
Build returns the built context.
func (*ContextBuilder) WithAcceptanceCriteria ¶
func (b *ContextBuilder) WithAcceptanceCriteria(count, checked int) *ContextBuilder
WithAcceptanceCriteria sets AC statistics.
func (*ContextBuilder) WithAlerts ¶
func (b *ContextBuilder) WithAlerts(count, critical, warning int) *ContextBuilder
WithAlerts sets alert statistics.
func (*ContextBuilder) WithDecisions ¶
func (b *ContextBuilder) WithDecisions(total, resolved int) *ContextBuilder
WithDecisions sets decision log statistics.
func (*ContextBuilder) WithDeploy ¶
func (b *ContextBuilder) WithDeploy(stagingStatus string, stagingHealthy bool, prodStatus string, prodHealthy bool) *ContextBuilder
WithDeploy sets deployment status.
func (*ContextBuilder) WithPRStack ¶
func (b *ContextBuilder) WithPRStack(exists bool, steps, completed int, allOpened, allApproved bool) *ContextBuilder
WithPRStack sets PR stack statistics.
func (*ContextBuilder) WithPRs ¶
func (b *ContextBuilder) WithPRs(open, approved int, threadsResolved bool) *ContextBuilder
WithPRs sets pull request statistics.
func (*ContextBuilder) WithSection ¶
func (b *ContextBuilder) WithSection(slug string, content string) *ContextBuilder
WithSection adds a section to the context.
func (*ContextBuilder) WithSections ¶
func (b *ContextBuilder) WithSections(sections map[string]string) *ContextBuilder
WithSections adds multiple sections to the context.
func (*ContextBuilder) WithSpec ¶
func (b *ContextBuilder) WithSpec(id, title, status string, labels []string, wordCount int, timeInStage time.Duration, revertCount int) *ContextBuilder
WithSpec sets spec metadata.
type DecisionsContext ¶
type DecisionsContext struct {
Total int `expr:"total"`
Resolved int `expr:"resolved"`
Unresolved int `expr:"unresolved"`
}
DecisionsContext contains decision log statistics.
type DeployContext ¶
type DeployContext struct {
Staging EnvironmentStatus `expr:"staging"`
Production EnvironmentStatus `expr:"production"`
}
DeployContext contains deployment status.
type EnvironmentStatus ¶
type EnvironmentStatus struct {
Status string `expr:"status"` // pending, running, success, failed
Healthy bool `expr:"healthy"`
}
EnvironmentStatus contains status for a deployment environment.
type ItemsContext ¶
type ItemsContext struct {
Count int `expr:"count"`
Checked int `expr:"checked"`
Unchecked int `expr:"unchecked"`
}
ItemsContext contains item count information.
type PRStackContext ¶
type PRStackContext struct {
Exists bool `expr:"exists"`
Steps int `expr:"steps"`
Completed int `expr:"completed"`
Pending int `expr:"pending"`
AllOpened bool `expr:"all_opened"`
AllApproved bool `expr:"all_approved"`
}
PRStackContext contains PR stack plan statistics.
type PRsContext ¶
type PRsContext struct {
Open int `expr:"open"`
Approved int `expr:"approved"`
Pending int `expr:"pending"`
ThreadsResolved bool `expr:"threads_resolved"`
}
PRsContext contains pull request statistics.
type SectionContext ¶
type SectionContext struct {
Empty bool `expr:"empty"`
WordCount int `expr:"word_count"`
LineCount int `expr:"line_count"`
}
SectionContext contains metadata about a spec section.
type SpecContext ¶
type SpecContext struct {
ID string `expr:"id"`
Title string `expr:"title"`
Status string `expr:"status"`
Labels []string `expr:"labels"`
TimeInStage time.Duration `expr:"time_in_stage"`
RevertCount int `expr:"revert_count"`
WordCount int `expr:"word_count"`
}
SpecContext contains spec metadata for expressions.