blacklist

package
v0.0.0-...-03d6fc4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Collection name for blacklist entries.
	COLLECTION_BLACKLISTS = "blacklist_rules"

	// We'll perform this many attempts for a given request.
	DEFAULT_ATTEMPTS = 3

	// Timeouts for various requests.
	TIMEOUT_GET = 60 * time.Second
	TIMEOUT_PUT = 10 * time.Second

	MAX_NAME_CHARS = 50
)

Variables

View Source
var (
	ERR_NO_SUCH_RULE = fmt.Errorf("No such rule.")
)

Functions

func ValidateRule

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

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

Types

type Blacklist

type Blacklist struct {
	// contains filtered or unexported fields
}

Blacklist is a struct which contains rules specifying tasks which should not be scheduled.

func New

func New(ctx context.Context, project, instance string, ts oauth2.TokenSource) (*Blacklist, error)

New returns a Blacklist instance.

func (*Blacklist) AddRule

func (b *Blacklist) AddRule(r *Rule, repos repograph.Map) error

Add adds a new Rule to the Blacklist.

func (*Blacklist) Close

func (b *Blacklist) Close() error

Close closes the database.

func (*Blacklist) GetRules

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

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

func (*Blacklist) Match

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

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

func (*Blacklist) MatchRule

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

MatchRule determines whether the given taskSpec/commit pair matches one of the Rules in the Blacklist. Returns the name of the matched Rule or the empty string if no Rules match.

func (*Blacklist) RemoveRule

func (b *Blacklist) RemoveRule(id string) error

RemoveRule removes the Rule from the Blacklist.

func (*Blacklist) Update

func (b *Blacklist) Update() error

Update updates the local view of the Blacklist 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.

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