Documentation ¶
Index ¶
- Constants
- Variables
- type AggregateStep
- type ArtifactOutputStep
- type BuildStepDelegate
- type DeprecationConfigSource
- type EmptyVersionSource
- type EnsureStep
- type ExitStatus
- type Factory
- type FileConfigSource
- type FileNotFoundError
- type GetDelegate
- type GetStep
- type IdentityStep
- type InputHandler
- type LogErrorStep
- type MergedConfigSource
- type MissingInputsError
- type MissingTaskImageSourceError
- type OnAbortStep
- type OnFailureStep
- type OnSuccessStep
- type OutputHandler
- type Privileged
- type PutDelegate
- type PutResourceSource
- type PutStep
- type PutStepVersionSource
- type RetryStep
- type RunState
- type StaticConfigSource
- type StaticVersionSource
- type Step
- func ArtifactOutput(id atc.PlanID, name worker.ArtifactName, delegate BuildStepDelegate) Step
- func LogError(step Step, delegate BuildStepDelegate) Step
- func NewGetStep(build db.Build, name string, resourceType string, resource string, ...) Step
- func NewTaskStep(privileged Privileged, configSource TaskConfigSource, tags atc.Tags, ...) Step
- func OnSuccess(firstStep Step, secondStep Step) Step
- func Retry(attempts ...Step) Step
- func Try(step Step) Step
- func UserArtifact(id atc.PlanID, name worker.ArtifactName, delegate BuildStepDelegate) Step
- type StepMetadata
- type TaskConfigSource
- type TaskDelegate
- type TaskImageSourceParametersError
- type TaskStep
- type TimeoutStep
- type TryStep
- type UnknownArtifactSourceError
- type UnspecifiedArtifactSourceError
- type UserArtifactStep
- type ValidatingConfigSource
- type VersionInfo
- type VersionSource
Constants ¶
const AbortedLogMessage = "interrupted"
const TimeoutLogMessage = "timeout exceeded"
Variables ¶
var ErrPutStepVersionMissing = errors.New("version is missing from put step")
Functions ¶
This section is empty.
Types ¶
type AggregateStep ¶
type AggregateStep []Step
AggregateStep is a step of steps to run in parallel.
func (AggregateStep) Run ¶
func (step AggregateStep) Run(ctx context.Context, state RunState) error
Run executes all steps in parallel. It will indicate that it's ready when all of its steps are ready, and propagate any signal received to all running steps.
It will wait for all steps to exit, even if one step fails or errors. After all steps finish, their errors (if any) will be aggregated and returned as a single error.
func (AggregateStep) Succeeded ¶
func (step AggregateStep) Succeeded() bool
Succeeded is true if all of the steps' Succeeded is true
type ArtifactOutputStep ¶
type ArtifactOutputStep struct {
// contains filtered or unexported fields
}
func (*ArtifactOutputStep) Run ¶
func (step *ArtifactOutputStep) Run(ctx context.Context, state RunState) error
func (*ArtifactOutputStep) Succeeded ¶
func (step *ArtifactOutputStep) Succeeded() bool
type BuildStepDelegate ¶
type DeprecationConfigSource ¶
type DeprecationConfigSource struct { Delegate TaskConfigSource Stderr io.Writer }
DeprecationConfigSource returns the Delegate TaskConfig and prints warnings to Stderr.
func (DeprecationConfigSource) FetchConfig ¶
func (configSource DeprecationConfigSource) FetchConfig(repo *worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig calls the Delegate's FetchConfig and prints warnings to Stderr
func (DeprecationConfigSource) Warnings ¶
func (configSource DeprecationConfigSource) Warnings() []string
type EmptyVersionSource ¶
type EmptyVersionSource struct{}
type EnsureStep ¶
type EnsureStep struct {
// contains filtered or unexported fields
}
EnsureStep will run one step, and then a second step regardless of whether the first step fails or errors.
func (EnsureStep) Run ¶
func (o EnsureStep) Run(ctx context.Context, state RunState) error
Run will call Run on the first step, wait for it to complete, and then call Run on the second step, regardless of whether the first step failed or errored.
If the first step or the second step errors, an aggregate of their errors is returned.
func (EnsureStep) Succeeded ¶
func (o EnsureStep) Succeeded() bool
Succeeded is true if both of its steps succeeded.
type ExitStatus ¶
type ExitStatus int
ExitStatus is the resulting exit code from the process that the step ran. Typically if the ExitStatus result is 0, the Success result is true.
type Factory ¶
type Factory interface { // Get constructs a Get step. Get( lager.Logger, atc.Plan, db.Build, StepMetadata, db.ContainerMetadata, GetDelegate, ) Step // Put constructs a Put step. Put( lager.Logger, atc.Plan, db.Build, StepMetadata, db.ContainerMetadata, PutDelegate, ) Step // Task constructs a Task step. Task( lager.Logger, atc.Plan, db.Build, db.ContainerMetadata, TaskDelegate, ) Step }
Factory is used when building up the steps for a build.
func NewGardenFactory ¶
func NewGardenFactory( workerClient worker.Client, resourceFetcher resource.Fetcher, resourceFactory resource.ResourceFactory, dbResourceCacheFactory db.ResourceCacheFactory, variablesFactory creds.VariablesFactory, ) Factory
type FileConfigSource ¶
type FileConfigSource struct {
Path string
}
FileConfigSource represents a dynamically configured TaskConfig, which will be fetched from a specified file in the worker.ArtifactRepository.
func (FileConfigSource) FetchConfig ¶
func (configSource FileConfigSource) FetchConfig(repo *worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig reads the specified file from the worker.ArtifactRepository and loads the TaskConfig contained therein (expecting it to be YAML format).
The path must be in the format SOURCE_NAME/FILE/PATH.yml. The SOURCE_NAME will be used to determine the ArtifactSource in the worker.ArtifactRepository to stream the file out of.
If the source name is missing (i.e. if the path is just "foo.yml"), UnspecifiedArtifactSourceError is returned.
If the specified source name cannot be found, UnknownArtifactSourceError is returned.
If the task config file is not found, or is invalid YAML, or is an invalid task configuration, the respective errors will be bubbled up.
func (FileConfigSource) Warnings ¶
func (configSource FileConfigSource) Warnings() []string
type FileNotFoundError ¶
type FileNotFoundError struct {
Path string
}
FileNotFoundError is the error to return from StreamFile when the given path does not exist.
func (FileNotFoundError) Error ¶
func (err FileNotFoundError) Error() string
Error prints a helpful message including the file path. The user will see this message if e.g. their task config path does not exist.
type GetDelegate ¶
type GetDelegate interface { BuildStepDelegate Finished(lager.Logger, ExitStatus, VersionInfo) }
type GetStep ¶
type GetStep struct {
// contains filtered or unexported fields
}
GetStep will fetch a version of a resource on a worker that supports the resource type.
func (*GetStep) Run ¶
Run ultimately registers the configured resource version's ArtifactSource under the configured SourceName. How it actually does this is determined by a few factors.
First, a worker that supports the given resource type is chosen, and a container is created on the worker.
If the worker has a VolumeManager, and its cache is already warmed, the cache will be mounted into the container, and no fetching will be performed. The container will be used to stream the contents of the cache to later steps that require the artifact but are running on a worker that does not have the cache.
If the worker does not have a VolumeManager, or if the worker does have a VolumeManager but a cache for the version of the resource is not present, the specified version of the resource will be fetched. As long as running the fetch script works, Run will return nil regardless of its exit status.
If the worker has a VolumeManager but did not have the cache initially, the fetched ArtifactSource is initialized, thus warming the worker's cache.
At the end, the resulting ArtifactSource (either from using the cache or fetching the resource) is registered under the step's SourceName.
type IdentityStep ¶
type IdentityStep struct{}
IdentityStep does nothing.
func (IdentityStep) Run ¶
func (IdentityStep) Run(context.Context, RunState) error
Run does nothing.
func (IdentityStep) Succeeded ¶
func (IdentityStep) Succeeded() bool
type InputHandler ¶
type InputHandler func(io.ReadCloser) error
type LogErrorStep ¶
type LogErrorStep struct { Step // contains filtered or unexported fields }
type MergedConfigSource ¶
type MergedConfigSource struct { A TaskConfigSource B TaskConfigSource }
MergedConfigSource is used to join two config sources together.
func (MergedConfigSource) FetchConfig ¶
func (configSource MergedConfigSource) FetchConfig(source *worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig fetches both config sources, and merges the second config source into the first. This allows the user to set params required by a task loaded from a file by providing them in static configuration.
func (MergedConfigSource) Warnings ¶
func (configSource MergedConfigSource) Warnings() []string
type MissingInputsError ¶
type MissingInputsError struct {
Inputs []string
}
MissingInputsError is returned when any of the task's required inputs are missing.
func (MissingInputsError) Error ¶
func (err MissingInputsError) Error() string
Error prints a human-friendly message listing the inputs that were missing.
type MissingTaskImageSourceError ¶
type MissingTaskImageSourceError struct {
SourceName string
}
func (MissingTaskImageSourceError) Error ¶
func (err MissingTaskImageSourceError) Error() string
type OnAbortStep ¶
type OnAbortStep struct {
// contains filtered or unexported fields
}
OnAbortStep will run one step, and then a second step if the first step aborts (but not errors).
func OnAbort ¶
func OnAbort(step Step, hook Step) OnAbortStep
OnAbort constructs an OnAbortStep factory.
func (OnAbortStep) Run ¶
func (o OnAbortStep) Run(ctx context.Context, state RunState) error
Run will call Run on the first step and wait for it to complete. If the first step errors, Run returns the error. OnAbortStep is ready as soon as the first step is ready.
If the first step aborts (that is, it gets interrupted), the second step is executed. If the second step errors, its error is returned.
func (OnAbortStep) Succeeded ¶
func (o OnAbortStep) Succeeded() bool
Succeeded is true if the first step doesn't exist, or if it completed successfully.
type OnFailureStep ¶
type OnFailureStep struct {
// contains filtered or unexported fields
}
OnFailureStep will run one step, and then a second step if the first step fails (but not errors).
func OnFailure ¶
func OnFailure(firstStep Step, secondStep Step) OnFailureStep
OnFailure constructs an OnFailureStep factory.
func (OnFailureStep) Run ¶
func (o OnFailureStep) Run(ctx context.Context, state RunState) error
Run will call Run on the first step and wait for it to complete. If the first step errors, Run returns the error. OnFailureStep is ready as soon as the first step is ready.
If the first step fails (that is, its Success result is false), the second step is executed. If the second step errors, its error is returned.
func (OnFailureStep) Succeeded ¶
func (o OnFailureStep) Succeeded() bool
Succeeded is true if the first step doesn't exist, or if it completed successfully.
type OnSuccessStep ¶
type OnSuccessStep struct {
// contains filtered or unexported fields
}
OnSuccessStep will run one step, and then a second step if the first step succeeds.
func (OnSuccessStep) Run ¶
func (o OnSuccessStep) Run(ctx context.Context, state RunState) error
Run will call Run on the first step and wait for it to complete. If the first step errors, Run returns the error. OnSuccessStep is ready as soon as the first step is ready.
If the first step succeeds (that is, its Success result is true), the second step is executed. If the second step errors, its error is returned.
func (OnSuccessStep) Succeeded ¶
func (o OnSuccessStep) Succeeded() bool
Succeeded is true if the first step completed and the second step completed successfully.
type OutputHandler ¶
type Privileged ¶
type Privileged bool
Privileged is used to indicate whether the given step should run with special privileges (i.e. as an administrator user).
type PutDelegate ¶
type PutDelegate interface { BuildStepDelegate Finished(lager.Logger, ExitStatus, VersionInfo) }
type PutResourceSource ¶
type PutResourceSource struct {
worker.ArtifactSource
}
func (PutResourceSource) StreamTo ¶
func (source PutResourceSource) StreamTo(dest worker.ArtifactDestination) error
type PutStep ¶
type PutStep struct {
// contains filtered or unexported fields
}
PutStep produces a resource version using preconfigured params and any data available in the worker.ArtifactRepository.
func NewPutStep ¶
func NewPutStep( build db.Build, name string, resourceType string, resourceName string, source creds.Source, params creds.Params, tags atc.Tags, delegate PutDelegate, resourceFactory resource.ResourceFactory, planID atc.PlanID, containerMetadata db.ContainerMetadata, stepMetadata StepMetadata, resourceTypes creds.VersionedResourceTypes, ) *PutStep
func (*PutStep) Run ¶
Run chooses a worker that supports the step's resource type and creates a container.
All worker.ArtifactSources present in the worker.ArtifactRepository are then brought into the container, using volumes if possible, and streaming content over if not.
The resource's put script is then invoked. If the context is canceled, the script will be interrupted.
func (*PutStep) VersionInfo ¶
func (step *PutStep) VersionInfo() VersionInfo
VersionInfo returns the info of the pushed version.
type PutStepVersionSource ¶
type PutStepVersionSource struct {
// contains filtered or unexported fields
}
type RetryStep ¶
RetryStep is a step that will run the steps in order until one of them succeeds.
type RunState ¶
type RunState interface { Artifacts() *worker.ArtifactRepository Result(atc.PlanID, interface{}) bool StoreResult(atc.PlanID, interface{}) SendUserInput(atc.PlanID, io.ReadCloser) ReadUserInput(atc.PlanID, InputHandler) error ReadPlanOutput(atc.PlanID, io.Writer) SendPlanOutput(atc.PlanID, OutputHandler) error }
func NewRunState ¶
func NewRunState() RunState
type StaticConfigSource ¶
StaticConfigSource represents a statically configured TaskConfig.
func (StaticConfigSource) FetchConfig ¶
func (configSource StaticConfigSource) FetchConfig(*worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig returns the configuration.
func (StaticConfigSource) Warnings ¶
func (configSource StaticConfigSource) Warnings() []string
type StaticVersionSource ¶
type StaticVersionSource struct {
// contains filtered or unexported fields
}
type Step ¶
type Step interface { // Run is called when it's time to execute the step. It should watch for the // given context to be canceled in the event that the build is aborted or the // step times out, and be sure to propagate the (context.Context).Err(). // // Steps wrapping other steps should be careful to propagate the context. // // Steps must be idempotent. Each step is responsible for handling its own // idempotency. Run(context.Context, RunState) error // Succeeded is true when the Step succeeded, and false otherwise. // Succeeded is not guaranteed to be truthful until after you run Run() Succeeded() bool }
A Step is an object that can be executed, whose result (e.g. Success) can be collected, and whose dependent resources (e.g. Containers, Volumes) can be released, allowing them to expire.
func ArtifactOutput ¶
func ArtifactOutput(id atc.PlanID, name worker.ArtifactName, delegate BuildStepDelegate) Step
func LogError ¶
func LogError(step Step, delegate BuildStepDelegate) Step
func NewGetStep ¶
func NewGetStep( build db.Build, name string, resourceType string, resource string, source creds.Source, params creds.Params, versionSource VersionSource, tags atc.Tags, delegate GetDelegate, resourceFetcher resource.Fetcher, teamID int, buildID int, planID atc.PlanID, containerMetadata db.ContainerMetadata, dbResourceCacheFactory db.ResourceCacheFactory, stepMetadata StepMetadata, resourceTypes creds.VersionedResourceTypes, ) Step
func NewTaskStep ¶
func NewTaskStep( privileged Privileged, configSource TaskConfigSource, tags atc.Tags, inputMapping map[string]string, outputMapping map[string]string, artifactsRoot string, imageArtifactName string, delegate TaskDelegate, workerPool worker.Client, teamID int, buildID int, jobID int, stepName string, planID atc.PlanID, containerMetadata db.ContainerMetadata, resourceTypes creds.VersionedResourceTypes, variables creds.Variables, ) Step
func UserArtifact ¶
func UserArtifact(id atc.PlanID, name worker.ArtifactName, delegate BuildStepDelegate) Step
type StepMetadata ¶
type StepMetadata interface {
Env() []string
}
StepMetadata is used to inject metadata to make available to the step when it's running.
type TaskConfigSource ¶
type TaskConfigSource interface { // FetchConfig returns the TaskConfig, and may have to a task config file out // of the worker.ArtifactRepository. FetchConfig(*worker.ArtifactRepository) (atc.TaskConfig, error) Warnings() []string }
TaskConfigSource is used to determine a Task step's TaskConfig.
type TaskDelegate ¶
type TaskDelegate interface { BuildStepDelegate Initializing(lager.Logger, atc.TaskConfig) Starting(lager.Logger, atc.TaskConfig) Finished(lager.Logger, ExitStatus) }
type TaskImageSourceParametersError ¶
type TaskImageSourceParametersError struct {
Err error
}
func (TaskImageSourceParametersError) Error ¶
func (err TaskImageSourceParametersError) Error() string
type TaskStep ¶
type TaskStep struct {
// contains filtered or unexported fields
}
TaskStep executes a TaskConfig, whose inputs will be fetched from the worker.ArtifactRepository and outputs will be added to the worker.ArtifactRepository.
func (*TaskStep) Run ¶
Run will first selects the worker based on the TaskConfig's platform, the TaskStep's tags, and prioritized by availability of volumes for the TaskConfig's inputs. Inputs that did not have volumes available on the worker will be streamed in to the container.
If any inputs are not available in the worker.ArtifactRepository, MissingInputsError is returned.
Once all the inputs are satisfied, the task's script will be executed. If the task is canceled via the context, the script will be interrupted.
If the script exits successfully, the outputs specified in the TaskConfig are registered with the worker.ArtifactRepository. If no outputs are specified, the task's entire working directory is registered as an ArtifactSource under the name of the task.
type TimeoutStep ¶
type TimeoutStep struct {
// contains filtered or unexported fields
}
TimeoutStep applies a fixed timeout to a step's Run.
func Timeout ¶
func Timeout(step Step, duration string) *TimeoutStep
Timeout constructs a TimeoutStep factory.
func (*TimeoutStep) Run ¶
func (ts *TimeoutStep) Run(ctx context.Context, state RunState) error
Run parses the timeout duration and invokes the nested step.
If the nested step takes longer than the duration, it is sent the Interrupt signal, and the TimeoutStep returns nil once the nested step exits (ignoring the nested step's error).
The result of the nested step's Run is returned.
func (*TimeoutStep) Succeeded ¶
func (ts *TimeoutStep) Succeeded() bool
Succeeded is true if the nested step completed successfully and did not time out.
type TryStep ¶
type TryStep struct {
// contains filtered or unexported fields
}
TryStep wraps another step, ignores its errors, and always succeeds.
type UnknownArtifactSourceError ¶
type UnknownArtifactSourceError struct {
SourceName worker.ArtifactName
}
UnknownArtifactSourceError is returned when the worker.ArtifactName specified by the path does not exist in the worker.ArtifactRepository.
func (UnknownArtifactSourceError) Error ¶
func (err UnknownArtifactSourceError) Error() string
Error returns a human-friendly error message.
type UnspecifiedArtifactSourceError ¶
type UnspecifiedArtifactSourceError struct {
Path string
}
UnspecifiedArtifactSourceError is returned when the specified path is of a file in the toplevel directory, and so it does not indicate a SourceName.
func (UnspecifiedArtifactSourceError) Error ¶
func (err UnspecifiedArtifactSourceError) Error() string
Error returns a human-friendly error message.
type UserArtifactStep ¶
type UserArtifactStep struct {
// contains filtered or unexported fields
}
func (*UserArtifactStep) Run ¶
func (step *UserArtifactStep) Run(ctx context.Context, state RunState) error
func (*UserArtifactStep) Succeeded ¶
func (step *UserArtifactStep) Succeeded() bool
type ValidatingConfigSource ¶
type ValidatingConfigSource struct {
ConfigSource TaskConfigSource
}
ValidatingConfigSource delegates to another ConfigSource, and validates its task config.
func (ValidatingConfigSource) FetchConfig ¶
func (configSource ValidatingConfigSource) FetchConfig(source *worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig fetches the config using the underlying ConfigSource, and checks that it's valid.
func (ValidatingConfigSource) Warnings ¶
func (configSource ValidatingConfigSource) Warnings() []string
type VersionInfo ¶
type VersionInfo struct { Version atc.Version Metadata []atc.MetadataField }
VersionInfo is the version and metadata of a resource that was fetched or produced. It is used by Put and Get.
type VersionSource ¶
func NewVersionSourceFromPlan ¶
func NewVersionSourceFromPlan(getPlan *atc.GetPlan) VersionSource
Source Files ¶
- aggregate.go
- artifact_output_step.go
- ensure_step.go
- errors.go
- factory.go
- file_read_closer.go
- garden_factory.go
- get_step.go
- identity_step.go
- log_error_step.go
- on_abort.go
- on_failure.go
- on_success.go
- progress.go
- put_step.go
- retry_step.go
- run_state.go
- step.go
- task_config_source.go
- task_step.go
- timeout_step.go
- try_step.go
- user_artifact_step.go
- version_source.go