builder

package
Version: v0.0.930 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 46 Imported by: 0

Documentation

Overview

Package builder is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleExit

func HandleExit(buildLogSteps []*contracts.BuildLogStep)

func RenderStats

func RenderStats(buildLogSteps []*contracts.BuildLogStep)

func WaitForReadinessHttpGet

func WaitForReadinessHttpGet(ctx context.Context, scheme, host string, port int, path, hostname string, timeoutSeconds int) error

Types

type CIBuilder

type CIBuilder interface {
	RunReadinessProbe(ctx context.Context, scheme, host string, port int, path, hostname string, timeoutSeconds int)
	RunEstafetteBuildJob(ctx context.Context, pipelineRunner PipelineRunner, containerRunner ContainerRunner, envvarHelper EnvvarHelper, obfuscator Obfuscator, endOfLifeHelper EndOfLifeHelper, builderConfig contracts.BuilderConfig, credentialsBytes []byte, runAsJob bool)
	RunLocalBuild(ctx context.Context, pipelineRunner PipelineRunner, containerRunner ContainerRunner, envvarHelper EnvvarHelper, builderConfig contracts.BuilderConfig, stagesToRun []string) (err error)
	RunGocdAgentBuild(ctx context.Context, pipelineRunner PipelineRunner, containerRunner ContainerRunner, envvarHelper EnvvarHelper, obfuscator Obfuscator, builderConfig contracts.BuilderConfig, credentialsBytes []byte)
	RunEstafetteCLIBuild() error
}

CIBuilder runs builds for different types of integrations

func NewCIBuilder

func NewCIBuilder(applicationInfo foundation.ApplicationInfo) CIBuilder

NewCIBuilder returns a new CIBuilder

type ContainerRunner

type ContainerRunner interface {
	IsImagePulled(ctx context.Context, stageName string, containerImage string) bool
	IsTrustedImage(stageName string, containerImage string) bool
	HasInjectedCredentials(stageName string, containerImage string) bool
	PullImage(ctx context.Context, stageName, parentStageName string, containerImage string) error
	GetImageSize(ctx context.Context, containerImage string) (int64, error)
	StartStageContainer(ctx context.Context, depth int, dir string, envvars map[string]string, stage manifest.EstafetteStage, stageIndex int) (containerID string, err error)
	StartServiceContainer(ctx context.Context, envvars map[string]string, service manifest.EstafetteService) (containerID string, err error)
	RunReadinessProbeContainer(ctx context.Context, parentStage manifest.EstafetteStage, service manifest.EstafetteService, readiness manifest.ReadinessProbe) (err error)
	TailContainerLogs(ctx context.Context, containerID, parentStageName, stageName string, stageType contracts.LogType, depth int, multiStage *bool) (err error)
	StopSingleStageServiceContainers(ctx context.Context, parentStage manifest.EstafetteStage)
	StopMultiStageServiceContainers(ctx context.Context)
	StartDockerDaemon() error
	WaitForDockerDaemon()
	CreateDockerClient() error
	CreateNetworks(ctx context.Context) error
	DeleteNetworks(ctx context.Context) error
	StopAllContainers(ctx context.Context)
	Info(ctx context.Context) string
}

ContainerRunner allows containers to be started

func NewDockerRunner

func NewDockerRunner(envvarHelper EnvvarHelper, obfuscator Obfuscator, config contracts.BuilderConfig, tailLogsChannel chan contracts.TailLogLine, runCommandsWithEntrypointScript bool) ContainerRunner

NewDockerRunner returns a new ContainerRunner to run containers using docker, either with docker-in-docker or docker-outside-docker

type EndOfLifeHelper

type EndOfLifeHelper interface {
	HandleFatal(context.Context, contracts.BuildLog, error, string)
	SendBuildStartedEvent(ctx context.Context) error
	SendBuildFinishedEvent(ctx context.Context, buildStatus contracts.LogStatus) error
	SendBuildCleanEvent(ctx context.Context, buildStatus contracts.LogStatus) error
	SendBuildJobLogEvent(ctx context.Context, buildLog contracts.BuildLog) error
	CancelJob(ctx context.Context) error
}

EndOfLifeHelper has methods to shutdown the runner after a fatal or successful run

func NewEndOfLifeHelper

func NewEndOfLifeHelper(runAsJob bool, config contracts.BuilderConfig, podName string) EndOfLifeHelper

NewEndOfLifeHelper returns a new EndOfLifeHelper

type EnvvarHelper

type EnvvarHelper interface {
	SetEstafetteGlobalEnvvars() error
	SetEstafetteBuilderConfigEnvvars(builderConfig contracts.BuilderConfig) error

	CollectEstafetteEnvvarsAndLabels(manifest.EstafetteManifest) (map[string]string, error)
	CollectGlobalEnvvars(manifest.EstafetteManifest) map[string]string
	UnsetEstafetteEnvvars()

	OverrideEnvvars(...map[string]string) map[string]string

	GetCiServer() string
	SetPipelineName(builderConfig contracts.BuilderConfig) error
	GetPipelineName() string
	GetWorkDir() string
	GetTempDir() string
	GetPodName() string
	GetPodUID() string
	GetPodNamespace() string
	GetPodNodeName() string
	// contains filtered or unexported methods
}

EnvvarHelper is the interface for getting, setting and retrieving ESTAFETTE_ environment variables

func NewEnvvarHelper

func NewEnvvarHelper(prefix string, secretHelper crypt.SecretHelper, obfuscator Obfuscator) EnvvarHelper

NewEnvvarHelper returns a new EnvvarHelper

type LocalFatalHandler

type LocalFatalHandler interface {
	HandleFatal(error, string)
}

LocalFatalHandler has methods to shutdown the runner after a fatal or successful run

func NewLocalFatalHandler

func NewLocalFatalHandler() LocalFatalHandler

NewLocalFatalHandler returns a new LocalFatalHandler

type MapMutex

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

func NewMapMutex

func NewMapMutex() *MapMutex

func (*MapMutex) Lock

func (m *MapMutex) Lock(key string)

func (*MapMutex) RLock

func (m *MapMutex) RLock(key string)

func (*MapMutex) RUnlock

func (m *MapMutex) RUnlock(key string)

func (*MapMutex) Unlock

func (m *MapMutex) Unlock(key string)

type MockContainerRunner

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

MockContainerRunner is a mock of ContainerRunner interface.

func NewMockContainerRunner

func NewMockContainerRunner(ctrl *gomock.Controller) *MockContainerRunner

NewMockContainerRunner creates a new mock instance.

func (*MockContainerRunner) CreateDockerClient

func (m *MockContainerRunner) CreateDockerClient() error

CreateDockerClient mocks base method.

func (*MockContainerRunner) CreateNetworks

func (m *MockContainerRunner) CreateNetworks(ctx context.Context) error

CreateNetworks mocks base method.

func (*MockContainerRunner) DeleteNetworks

func (m *MockContainerRunner) DeleteNetworks(ctx context.Context) error

DeleteNetworks mocks base method.

func (*MockContainerRunner) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockContainerRunner) GetImageSize

func (m *MockContainerRunner) GetImageSize(ctx context.Context, containerImage string) (int64, error)

GetImageSize mocks base method.

func (*MockContainerRunner) HasInjectedCredentials

func (m *MockContainerRunner) HasInjectedCredentials(stageName, containerImage string) bool

HasInjectedCredentials mocks base method.

func (*MockContainerRunner) Info

Info mocks base method.

func (*MockContainerRunner) IsImagePulled

func (m *MockContainerRunner) IsImagePulled(ctx context.Context, stageName, containerImage string) bool

IsImagePulled mocks base method.

func (*MockContainerRunner) IsTrustedImage

func (m *MockContainerRunner) IsTrustedImage(stageName, containerImage string) bool

IsTrustedImage mocks base method.

func (*MockContainerRunner) PullImage

func (m *MockContainerRunner) PullImage(ctx context.Context, stageName, parentStageName, containerImage string) error

PullImage mocks base method.

func (*MockContainerRunner) RunReadinessProbeContainer

func (m *MockContainerRunner) RunReadinessProbeContainer(ctx context.Context, parentStage manifest.EstafetteStage, service manifest.EstafetteService, readiness manifest.ReadinessProbe) error

RunReadinessProbeContainer mocks base method.

func (*MockContainerRunner) StartDockerDaemon

func (m *MockContainerRunner) StartDockerDaemon() error

StartDockerDaemon mocks base method.

func (*MockContainerRunner) StartServiceContainer

func (m *MockContainerRunner) StartServiceContainer(ctx context.Context, envvars map[string]string, service manifest.EstafetteService) (string, error)

StartServiceContainer mocks base method.

func (*MockContainerRunner) StartStageContainer

func (m *MockContainerRunner) StartStageContainer(ctx context.Context, depth int, dir string, envvars map[string]string, stage manifest.EstafetteStage, stageIndex int) (string, error)

StartStageContainer mocks base method.

func (*MockContainerRunner) StopAllContainers

func (m *MockContainerRunner) StopAllContainers(ctx context.Context)

StopAllContainers mocks base method.

func (*MockContainerRunner) StopMultiStageServiceContainers

func (m *MockContainerRunner) StopMultiStageServiceContainers(ctx context.Context)

StopMultiStageServiceContainers mocks base method.

func (*MockContainerRunner) StopSingleStageServiceContainers

func (m *MockContainerRunner) StopSingleStageServiceContainers(ctx context.Context, parentStage manifest.EstafetteStage)

StopSingleStageServiceContainers mocks base method.

func (*MockContainerRunner) TailContainerLogs

func (m *MockContainerRunner) TailContainerLogs(ctx context.Context, containerID, parentStageName, stageName string, stageType contracts.LogType, depth int, multiStage *bool) error

TailContainerLogs mocks base method.

func (*MockContainerRunner) WaitForDockerDaemon

func (m *MockContainerRunner) WaitForDockerDaemon()

WaitForDockerDaemon mocks base method.

type MockContainerRunnerMockRecorder

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

MockContainerRunnerMockRecorder is the mock recorder for MockContainerRunner.

func (*MockContainerRunnerMockRecorder) CreateDockerClient

func (mr *MockContainerRunnerMockRecorder) CreateDockerClient() *gomock.Call

CreateDockerClient indicates an expected call of CreateDockerClient.

func (*MockContainerRunnerMockRecorder) CreateNetworks

func (mr *MockContainerRunnerMockRecorder) CreateNetworks(ctx interface{}) *gomock.Call

CreateNetworks indicates an expected call of CreateNetworks.

func (*MockContainerRunnerMockRecorder) DeleteNetworks

func (mr *MockContainerRunnerMockRecorder) DeleteNetworks(ctx interface{}) *gomock.Call

DeleteNetworks indicates an expected call of DeleteNetworks.

func (*MockContainerRunnerMockRecorder) GetImageSize

func (mr *MockContainerRunnerMockRecorder) GetImageSize(ctx, containerImage interface{}) *gomock.Call

GetImageSize indicates an expected call of GetImageSize.

func (*MockContainerRunnerMockRecorder) HasInjectedCredentials

func (mr *MockContainerRunnerMockRecorder) HasInjectedCredentials(stageName, containerImage interface{}) *gomock.Call

HasInjectedCredentials indicates an expected call of HasInjectedCredentials.

func (*MockContainerRunnerMockRecorder) Info

func (mr *MockContainerRunnerMockRecorder) Info(ctx interface{}) *gomock.Call

Info indicates an expected call of Info.

func (*MockContainerRunnerMockRecorder) IsImagePulled

func (mr *MockContainerRunnerMockRecorder) IsImagePulled(ctx, stageName, containerImage interface{}) *gomock.Call

IsImagePulled indicates an expected call of IsImagePulled.

func (*MockContainerRunnerMockRecorder) IsTrustedImage

func (mr *MockContainerRunnerMockRecorder) IsTrustedImage(stageName, containerImage interface{}) *gomock.Call

IsTrustedImage indicates an expected call of IsTrustedImage.

func (*MockContainerRunnerMockRecorder) PullImage

func (mr *MockContainerRunnerMockRecorder) PullImage(ctx, stageName, parentStageName, containerImage interface{}) *gomock.Call

PullImage indicates an expected call of PullImage.

func (*MockContainerRunnerMockRecorder) RunReadinessProbeContainer

func (mr *MockContainerRunnerMockRecorder) RunReadinessProbeContainer(ctx, parentStage, service, readiness interface{}) *gomock.Call

RunReadinessProbeContainer indicates an expected call of RunReadinessProbeContainer.

func (*MockContainerRunnerMockRecorder) StartDockerDaemon

func (mr *MockContainerRunnerMockRecorder) StartDockerDaemon() *gomock.Call

StartDockerDaemon indicates an expected call of StartDockerDaemon.

func (*MockContainerRunnerMockRecorder) StartServiceContainer

func (mr *MockContainerRunnerMockRecorder) StartServiceContainer(ctx, envvars, service interface{}) *gomock.Call

StartServiceContainer indicates an expected call of StartServiceContainer.

func (*MockContainerRunnerMockRecorder) StartStageContainer

func (mr *MockContainerRunnerMockRecorder) StartStageContainer(ctx, depth, dir, envvars, stage, stageIndex interface{}) *gomock.Call

StartStageContainer indicates an expected call of StartStageContainer.

func (*MockContainerRunnerMockRecorder) StopAllContainers

func (mr *MockContainerRunnerMockRecorder) StopAllContainers(ctx interface{}) *gomock.Call

StopAllContainers indicates an expected call of StopAllContainers.

func (*MockContainerRunnerMockRecorder) StopMultiStageServiceContainers

func (mr *MockContainerRunnerMockRecorder) StopMultiStageServiceContainers(ctx interface{}) *gomock.Call

StopMultiStageServiceContainers indicates an expected call of StopMultiStageServiceContainers.

func (*MockContainerRunnerMockRecorder) StopSingleStageServiceContainers

func (mr *MockContainerRunnerMockRecorder) StopSingleStageServiceContainers(ctx, parentStage interface{}) *gomock.Call

StopSingleStageServiceContainers indicates an expected call of StopSingleStageServiceContainers.

func (*MockContainerRunnerMockRecorder) TailContainerLogs

func (mr *MockContainerRunnerMockRecorder) TailContainerLogs(ctx, containerID, parentStageName, stageName, stageType, depth, multiStage interface{}) *gomock.Call

TailContainerLogs indicates an expected call of TailContainerLogs.

func (*MockContainerRunnerMockRecorder) WaitForDockerDaemon

func (mr *MockContainerRunnerMockRecorder) WaitForDockerDaemon() *gomock.Call

WaitForDockerDaemon indicates an expected call of WaitForDockerDaemon.

type Obfuscator

type Obfuscator interface {
	CollectSecrets(manifest manifest.EstafetteManifest, credentialsBytes []byte, pipeline string) (err error)
	Obfuscate(input string) string
	ObfuscateSecrets(input string) string
}

Obfuscator hides secret values and other sensitive stuff from the logs

func NewObfuscator

func NewObfuscator(secretHelper crypt.SecretHelper) Obfuscator

NewObfuscator returns a new Obfuscator

type PipelineRunner

type PipelineRunner interface {
	RunStage(ctx context.Context, depth int, dir string, envvars map[string]string, parentStage *manifest.EstafetteStage, stage manifest.EstafetteStage, stageIndex int) (err error)
	RunService(ctx context.Context, envvars map[string]string, parentStage manifest.EstafetteStage, service manifest.EstafetteService) (err error)
	RunStages(ctx context.Context, depth int, stages []*manifest.EstafetteStage, dir string, envvars map[string]string) (buildLogSteps []*contracts.BuildLogStep, err error)
	RunParallelStages(ctx context.Context, depth int, dir string, envvars map[string]string, parentStage manifest.EstafetteStage, parallelStages []*manifest.EstafetteStage) (err error)
	RunServices(ctx context.Context, envvars map[string]string, parentStage manifest.EstafetteStage, services []*manifest.EstafetteService) (err error)
	StopPipelineOnCancellation(ctx context.Context)
	EnableBuilderInfoStageInjection()
}

PipelineRunner is the interface for running the pipeline steps

func NewPipelineRunner

func NewPipelineRunner(envvarHelper EnvvarHelper, whenEvaluator WhenEvaluator, containerRunner ContainerRunner, runAsJob bool, tailLogsChannel chan contracts.TailLogLine, applicationInfo foundation.ApplicationInfo) PipelineRunner

NewPipelineRunner returns a new PipelineRunner

type WhenEvaluator

type WhenEvaluator interface {
	Evaluate(string, string, map[string]interface{}) (bool, error)
	GetParameters() map[string]interface{}
}

WhenEvaluator evaluates when clauses from the manifest

func NewWhenEvaluator

func NewWhenEvaluator(envvarHelper EnvvarHelper) WhenEvaluator

NewWhenEvaluator returns a new WhenEvaluator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL