Documentation ¶
Index ¶
- func ValidateRule(r *Rule, repos repograph.Map) error
- type DB
- func (b *DB) AddRule(ctx context.Context, r *Rule, repos repograph.Map) error
- func (b *DB) AutoUpdate(ctx context.Context)
- func (b *DB) Close() error
- func (b *DB) GetRules() []*Rule
- func (b *DB) Match(taskSpec, commit string) bool
- func (b *DB) MatchRule(taskSpec, commit string) string
- func (b *DB) RemoveRule(ctx context.Context, id string) error
- func (b *DB) Update(ctx context.Context) error
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a struct which contains rules specifying tasks which should not be scheduled.
func NewWithParams ¶
func NewWithParams(ctx context.Context, project, instance string, ts oauth2.TokenSource) (*DB, error)
NewWithParams returns a DB instance backed by Firestore, using the given params.
func (*DB) AutoUpdate ¶
AutoUpdate starts a goroutine which automatically updates the DB as changes occur. Starts the goroutine and returns immediately. The goroutine exits when the given context expires.
func (*DB) Match ¶
Match determines whether the given taskSpec/commit pair matches one of the Rules in the DB.
func (*DB) MatchRule ¶
MatchRule determines whether the given taskSpec/commit pair matches one of the Rules in the DB. Returns the name of the matched Rule or the empty string if no Rules match.
func (*DB) RemoveRule ¶
RemoveRule removes the Rule from the DB.
type Rule ¶
type Rule struct { AddedBy string `json:"added_by"` TaskSpecPatterns []string `json:"task_spec_patterns"` Commits []string `json:"commits"` Description string `json:"description"` Name string `json:"name"` }
Rule is a struct which indicates a specific task or set of tasks which should not be scheduled.
TaskSpecPatterns consists of regular expressions used to match taskSpecs which should not be triggered according to this Rule.
Commits are simply commit hashes for which the rule applies. If the list is empty, the Rule applies for all commits.
A Rule should specify TaskSpecPatterns or Commits or both.
TODO(borenet): Add an explicit ID field and a timestamp.