policy

package
v3.6.0-alpha.2+incompa... Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNextConfigBuild

func GetNextConfigBuild(lister buildclient.BuildLister, namespace, buildConfigName string) ([]*buildapi.Build, bool, error)

GetNextConfigBuild returns the build that will be executed next for the given build configuration. It also returns the indication whether there are currently running builds, to make sure there is no race-condition between re-listing the builds.

func NewNoBuildNumberAnnotationError

func NewNoBuildNumberAnnotationError(build *buildapi.Build) error

Types

type NoBuildNumberAnnotationError

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

NoBuildNumberLabelError represents an error caused by the build not having the required build number annotation.

func (NoBuildNumberAnnotationError) Error

type ParallelPolicy

type ParallelPolicy struct {
	BuildLister  buildclient.BuildLister
	BuildUpdater buildclient.BuildUpdater
}

ParallelPolicy implements the RunPolicy interface. Build created using this run policy will always run as soon as they are created. This run policy does not guarantee that the builds will complete in same order as they were created and using this policy might cause unpredictable behavior.

func (*ParallelPolicy) IsRunnable

func (s *ParallelPolicy) IsRunnable(build *buildapi.Build) (bool, error)

IsRunnable implements the RunPolicy interface. The parallel builds are run as soon as they are created. There is no build queue as all build run asynchronously.

func (*ParallelPolicy) OnComplete

func (s *ParallelPolicy) OnComplete(build *buildapi.Build) error

OnComplete implements the RunPolicy interface.

type RunPolicy

type RunPolicy interface {
	// IsRunnable returns true of the given build should be executed.
	IsRunnable(*buildapi.Build) (bool, error)

	// OnComplete allows policy to execute action when the given build just
	// completed.
	OnComplete(*buildapi.Build) error
}

RunPolicy is an interface that define handler for the build runPolicy field. The run policy controls how and when the new builds are 'run'.

func ForBuild

func ForBuild(build *buildapi.Build, policies []RunPolicy) RunPolicy

ForBuild picks the appropriate run policy for the given build.

func GetAllRunPolicies

func GetAllRunPolicies(lister buildclient.BuildLister, updater buildclient.BuildUpdater) []RunPolicy

GetAllRunPolicies returns a set of all run policies.

type SerialLatestOnlyPolicy

type SerialLatestOnlyPolicy struct {
	BuildUpdater buildclient.BuildUpdater
	BuildLister  buildclient.BuildLister
}

SerialLatestOnlyPolicy implements the RunPolicy interface. This variant of the serial build policy makes sure that builds are executed in same order as they were created, but when a new build is created, the previous, queued build is cancelled, always making the latest created build run as next. This will produce consistent results, but might not suit the CI/CD flow where user expect that every commit is built.

func (*SerialLatestOnlyPolicy) IsRunnable

func (s *SerialLatestOnlyPolicy) IsRunnable(build *buildapi.Build) (bool, error)

IsRunnable implements the RunPolicy interface. Calling this function on a build mean that any previous build that is in 'new' phase will be automatically cancelled. This will also cancel any "serial" build (when you changed the build config run policy on-the-fly).

func (*SerialLatestOnlyPolicy) OnComplete

func (s *SerialLatestOnlyPolicy) OnComplete(build *buildapi.Build) error

IsRunnable implements the Scheduler interface.

type SerialPolicy

type SerialPolicy struct {
	BuildLister  buildclient.BuildLister
	BuildUpdater buildclient.BuildUpdater
}

SerialPolicy implements the RunPolicy interface. Using this run policy, every created build is put into a queue. The serial run policy guarantees that all builds are executed synchroniously in the same order as they were created. This will produce consistent results, but block the build execution until the previous builds are complete.

func (*SerialPolicy) IsRunnable

func (s *SerialPolicy) IsRunnable(build *buildapi.Build) (bool, error)

IsRunnable implements the RunPolicy interface.

func (*SerialPolicy) OnComplete

func (s *SerialPolicy) OnComplete(build *buildapi.Build) error

OnComplete implements the RunPolicy interface.

Jump to

Keyboard shortcuts

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