skip_tasks

package
v0.0.0-...-ac9bbf9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateRule

func ValidateRule(r *Rule, repos repograph.Map) error

ValidateRule returns an error if the given Rule is not valid.

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 New

func New(ctx context.Context, client *firestore.Client) (*DB, error)

New returns a DB instance backed by the given firestore.Client.

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) AddRule

func (b *DB) AddRule(ctx context.Context, r *Rule, repos repograph.Map) error

Add adds a new Rule to the DB.

func (*DB) AutoUpdate

func (b *DB) AutoUpdate(ctx context.Context)

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) Close

func (b *DB) Close() error

Close closes the database.

func (*DB) GetRules

func (b *DB) GetRules() []*Rule

GetRules returns a slice containing all of the Rules in the DB.

func (*DB) Match

func (b *DB) Match(taskSpec, commit string) bool

Match determines whether the given taskSpec/commit pair matches one of the Rules in the DB.

func (*DB) MatchRule

func (b *DB) MatchRule(taskSpec, commit string) string

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

func (b *DB) RemoveRule(ctx context.Context, id string) error

RemoveRule removes the Rule from the DB.

func (*DB) Update

func (b *DB) Update(ctx context.Context) error

Update updates the local view of the skip rules to match the remote 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.

func NewCommitRangeRule

func NewCommitRangeRule(ctx context.Context, name, user, description string, taskSpecPatterns []string, startCommit, endCommit string, repos repograph.Map) (*Rule, error)

NewCommitRangeRule creates a new Rule which covers a range of commits.

func (*Rule) Copy

func (r *Rule) Copy() *Rule

Copy returns a deep copy of the Rule.

func (*Rule) Match

func (r *Rule) Match(taskSpec, commit string) bool

Match returns true iff the Rule matches the given taskSpec and commit.

Jump to

Keyboard shortcuts

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