trigger

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

	trigger contains the logic for determining whether or not stages and/or commits pushed to a given
	  repository should be executed.
	this includes:
	  - checking if a given branch matches a regex list of acceptable branches
      - a parser for the sentence-like conditions that can be used in a build stage
	  - support for 3 types of trigger conditions:
		- match filepaths changed
		- match text in commit messages
   		- match branch

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchRegexOk

func BranchRegexOk(branch string, buildBranches []string) (bool, error)

BranchRegexOk will attempt to do a regex match on each of the build branches. it will return true if any entry is 'ALL' or if there was a successful regex match.

An error will be returned if one of the build branches fails to be compiled into a regex expression

Types

type BranchCondition

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

func (*BranchCondition) AddConditionValue

func (b *BranchCondition) AddConditionValue(str string)

AddConditionalValue will add to the list of branches that will be checked against in PassesMuster

func (*BranchCondition) GetConditionValues

func (b *BranchCondition) GetConditionValues() []string

func (*BranchCondition) GetLogical

func (b *BranchCondition) GetLogical() Conditional

func (*BranchCondition) GetTriggerType

func (b *BranchCondition) GetTriggerType() TriggerType

func (*BranchCondition) PassesMuster

func (b *BranchCondition) PassesMuster(td *pb.ChangesetData) bool

PassesMuster will check to make sure the branch in the changeset data regex matches with at least one of the accepted branches in its list

func (*BranchCondition) SetLogical

func (b *BranchCondition) SetLogical(conditional Conditional)

type Conditional

type Conditional int
const (
	CNone Conditional = iota
	Or
	And
)

func (Conditional) String

func (i Conditional) String() string

type ConditionalDirective

type ConditionalDirective struct {
	Conditions []Section
	Logical    Conditional
}

func Parse

func Parse(directive string) (*ConditionalDirective, error)

func (*ConditionalDirective) IsFulfilled

func (c *ConditionalDirective) IsFulfilled(td *pb.ChangesetData) bool

type ConditionalSection

type ConditionalSection struct {
	Ttype   TriggerType
	Values  []string
	Logical Conditional
	// contains filtered or unexported fields
}

type ErrNotSupported

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

func CannotCombineSymbols

func CannotCombineSymbols() *ErrNotSupported

func MustStartWithAction

func MustStartWithAction() *ErrNotSupported

func NotSupported

func NotSupported(msg string) *ErrNotSupported

func (*ErrNotSupported) Error

func (e *ErrNotSupported) Error() string

type FilepathCondition

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

func (*FilepathCondition) AddConditionValue

func (b *FilepathCondition) AddConditionValue(str string)

func (*FilepathCondition) GetConditionValues

func (b *FilepathCondition) GetConditionValues() []string

func (*FilepathCondition) GetLogical

func (b *FilepathCondition) GetLogical() Conditional

func (*FilepathCondition) GetTriggerType

func (b *FilepathCondition) GetTriggerType() TriggerType

func (*FilepathCondition) PassesMuster

func (b *FilepathCondition) PassesMuster(td *pb.ChangesetData) bool

PassesMuster will make sure that the filepaths supplied as conditional values are found in the changeset data.

This is done along two different paths:
  If the GetLogical() is OR:
    At least one of the supplied filepaths given in the conditional values added by AddConditionalValue() must be
    in the list of changed files in the ChangesetData
  If the GetLogical() is AND:
    All supplied filepaths given in the conditional values added by AddConditionalValue() must be
    in the list of changed files in the ChangesetData

func (*FilepathCondition) SetLogical

func (b *FilepathCondition) SetLogical(conditional Conditional)

type Section

type Section interface {
	GetTriggerType() TriggerType
	// PassesMuster should be going through the relevant changeset data that it is given and figuring out
	//  if its trigger type is fulfilled in that given set. For example, the Branch TriggerType will be making sure the active
	//  branch in the changeset data regex matches with at least one of the branches in its acceptable branches list
	PassesMuster(*pb.ChangesetData) bool
	// GetLogical will retrieve the type of logical and/or that should be used for each condition value given for this particular trigger type
	GetLogical() Conditional
	SetLogical(Conditional)
	// AddConditionValue should add to the list of values that PassesMuster will check against. The ConditionValue for example
	//  could be 'master', or 'develop', etc for branches
	AddConditionValue(string)
	// GetConditionValues returns all the conditions values that have been added for that section. E.g. []string{"master", "develop", "release\/.*"} for branch
	GetConditionValues() []string
}

type TextCondition

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

func (*TextCondition) AddConditionValue

func (b *TextCondition) AddConditionValue(str string)

func (*TextCondition) GetConditionValues

func (b *TextCondition) GetConditionValues() []string

func (*TextCondition) GetLogical

func (b *TextCondition) GetLogical() Conditional

func (*TextCondition) GetTriggerType

func (b *TextCondition) GetTriggerType() TriggerType

func (*TextCondition) PassesMuster

func (b *TextCondition) PassesMuster(td *pb.ChangesetData) bool

PassesMuster will make sure that the text supplied as conditional values is found in the changeset data.

This is done along two different paths:
  If the GetLogical() is OR:
    At least one of the supplied commit texts given in the conditional values must be found in the
    commit messages in the changeset data
  If the GetLogical() is AND:
    Every supplied commit text given in the conditional values must be found in the commit messages

func (*TextCondition) SetLogical

func (b *TextCondition) SetLogical(conditional Conditional)

type TriggerType

type TriggerType int
const (
	TNone TriggerType = iota
	Branch
	Filepath
	Text
)

func (TriggerType) Spawn

func (t TriggerType) Spawn() Section

func (TriggerType) String

func (i TriggerType) String() string

Jump to

Keyboard shortcuts

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