policy

package
v3.10.0-rc.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 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 buildlister.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  buildlister.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) Handles

func (s *ParallelPolicy) Handles(policy buildapi.BuildRunPolicy) bool

Handles returns true for the build run parallel policy

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.

type RunPolicy

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

	// Handles returns true if the run policy handles a specific policy
	Handles(buildapi.BuildRunPolicy) bool
}

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 buildlister.BuildLister, updater buildclient.BuildUpdater) []RunPolicy

GetAllRunPolicies returns a set of all run policies.

type SerialLatestOnlyPolicy

type SerialLatestOnlyPolicy struct {
	BuildUpdater buildclient.BuildUpdater
	BuildLister  buildlister.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) Handles

Handles returns true for the build run serial latest only policy

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

type SerialPolicy

type SerialPolicy struct {
	BuildLister  buildlister.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) Handles

func (s *SerialPolicy) Handles(policy buildapi.BuildRunPolicy) bool

Handles returns true for the build run serial policy

func (*SerialPolicy) IsRunnable

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

IsRunnable implements the RunPolicy interface.

Jump to

Keyboard shortcuts

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