Documentation ¶
Index ¶
- Variables
- type Action
- type ActionsBuildEventsDelegate
- type ActionsStep
- type Aggregate
- type AggregateStep
- type ConfigFetcher
- type DeprecationConfigFetcher
- type EmptyVersionSource
- type EnsureStep
- type ExitStatus
- type Factory
- type FetchConfigAction
- type FetchConfigActionTaskConfigSource
- type FetchConfigResultAction
- type FileConfigFetcher
- type FileNotFoundError
- type GetAction
- type GetStep
- type GetStepFactory
- type Identity
- type IdentityStep
- type ImageFetchingDelegate
- type MergedConfigFetcher
- type MissingInputsError
- type MissingTaskImageSourceError
- type OnFailureStep
- type OnSuccessStep
- type Privileged
- type PutAction
- type PutActionVersionSource
- type PutResourceSource
- type PutStep
- type PutStepFactory
- type Retry
- type RetryStep
- type StaticConfigFetcher
- type StaticVersionSource
- type Step
- type StepFactory
- type StepMetadata
- type Success
- type TaskAction
- type TaskBuildEventsDelegate
- type TaskConfigFetcher
- type TaskConfigSource
- type TaskImageSourceParametersError
- type TaskStep
- type TaskStepFactory
- type TimeoutStep
- type TryStep
- type UnknownArtifactSourceError
- type UnspecifiedArtifactSourceError
- type ValidatingConfigFetcher
- type VersionInfo
- type VersionSource
Constants ¶
This section is empty.
Variables ¶
var ErrInterrupted = errors.New("interrupted")
ErrInterrupted is returned by steps when they exited as a result of receiving a signal.
var ErrPutActionVersionMissing = errors.New("version is missing from put action")
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { Run(lager.Logger, *worker.ArtifactRepository, <-chan os.Signal, chan<- struct{}) error ExitStatus() ExitStatus }
type ActionsStep ¶
type ActionsStep struct {
// contains filtered or unexported fields
}
ActionsStep will execute actions in specified order and notify build events delegate about different execution events.
func NewActionsStep ¶
func NewActionsStep( logger lager.Logger, actions []Action, buildEventsDelegate ActionsBuildEventsDelegate, ) ActionsStep
func (*ActionsStep) Run ¶
func (s *ActionsStep) Run(signals <-chan os.Signal, ready chan<- struct{}) error
Run will first call Initializing on build events delegate. Then it will call Run on every action. If any action fails it will notify delegate with Failed. It will call ActionCompleted after each action run that succeeds.
func (*ActionsStep) Succeeded ¶
func (s *ActionsStep) Succeeded() bool
Succeeded will return true if all actions exited with exit status 0.
func (ActionsStep) Using ¶
func (s ActionsStep) Using(repo *worker.ArtifactRepository) Step
type Aggregate ¶
type Aggregate []StepFactory
Aggregate constructs a Step that will run each step in parallel.
type AggregateStep ¶
type AggregateStep []Step
AggregateStep is a step of steps to run in parallel.
func (AggregateStep) Run ¶
func (step AggregateStep) Run(signals <-chan os.Signal, ready chan<- struct{}) 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 ConfigFetcher ¶
type ConfigFetcher interface {
FetchConfig(repository *worker.ArtifactRepository) (atc.TaskConfig, error)
}
type DeprecationConfigFetcher ¶
type DeprecationConfigFetcher struct { Delegate TaskConfigFetcher Stderr io.Writer }
DeprecationConfigFetcher returns the Delegate TaskConfig and prints warnings to Stderr.
func (DeprecationConfigFetcher) FetchConfig ¶
func (configFetcher DeprecationConfigFetcher) FetchConfig(repo *worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig calls the Delegate's FetchConfig and prints warnings to Stderr
func (DeprecationConfigFetcher) Warnings ¶
func (configFetcher DeprecationConfigFetcher) Warnings() []string
type EmptyVersionSource ¶
type EmptyVersionSource struct{}
func (*EmptyVersionSource) GetVersion ¶
func (p *EmptyVersionSource) GetVersion() (atc.Version, error)
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 Ensure ¶
func Ensure(firstStep StepFactory, secondStep StepFactory) EnsureStep
Ensure constructs an EnsureStep factory.
func (*EnsureStep) Run ¶
func (o *EnsureStep) Run(signals <-chan os.Signal, ready chan<- struct{}) 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 are true
func (EnsureStep) Using ¶
func (o EnsureStep) Using(repo *worker.ArtifactRepository) Step
Using constructs an *EnsureStep.
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 ActionsStep factory for Get. Get( lager.Logger, atc.Plan, db.Build, StepMetadata, db.ContainerMetadata, ActionsBuildEventsDelegate, ImageFetchingDelegate, ) StepFactory // Put constructs a ActionsStep factory for Put. Put( lager.Logger, atc.Plan, db.Build, StepMetadata, db.ContainerMetadata, ActionsBuildEventsDelegate, ImageFetchingDelegate, ) StepFactory // Task constructs a ActionsStep factory for Task. Task( lager.Logger, atc.Plan, db.Build, db.ContainerMetadata, TaskBuildEventsDelegate, ActionsBuildEventsDelegate, ImageFetchingDelegate, ) StepFactory }
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 FetchConfigAction ¶
type FetchConfigAction struct {
// contains filtered or unexported fields
}
FetchConfigAction fetches task config based on config source, either statically provided or dynamically loaded from worker.ArtifactRepository.
func (*FetchConfigAction) ExitStatus ¶
func (action *FetchConfigAction) ExitStatus() ExitStatus
ExitStatus always 0. Fetching config might error but it does not produce any exit status.
func (*FetchConfigAction) Result ¶
func (action *FetchConfigAction) Result() atc.TaskConfig
Result returns the fetched atc.TaskConfig
func (*FetchConfigAction) Run ¶
func (action *FetchConfigAction) Run( logger lager.Logger, repository *worker.ArtifactRepository, signals <-chan os.Signal, ready chan<- struct{}, ) error
Run first load the TaskConfig
type FetchConfigActionTaskConfigSource ¶
type FetchConfigActionTaskConfigSource struct {
Action FetchConfigResultAction
}
func (*FetchConfigActionTaskConfigSource) GetTaskConfig ¶
func (s *FetchConfigActionTaskConfigSource) GetTaskConfig() (atc.TaskConfig, error)
type FetchConfigResultAction ¶
type FetchConfigResultAction interface {
Result() atc.TaskConfig
}
type FileConfigFetcher ¶
type FileConfigFetcher struct {
Path string
}
FileConfigFetcher represents a dynamically configured TaskConfig, which will be fetched from a specified file in the worker.ArtifactRepository.
func (FileConfigFetcher) FetchConfig ¶
func (configFetcher FileConfigFetcher) 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 (FileConfigFetcher) Warnings ¶
func (configFetcher FileConfigFetcher) 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 GetAction ¶
type GetAction struct { Type string Name string Resource string Source creds.Source Params atc.Params VersionSource VersionSource Tags atc.Tags Outputs []string // contains filtered or unexported fields }
GetAction will fetch a version of a resource on a worker that supports the resource type.
func (*GetAction) ExitStatus ¶
func (action *GetAction) ExitStatus() ExitStatus
ExitStatus returns exit status of resource get script.
func (*GetAction) Run ¶
func (action *GetAction) Run( logger lager.Logger, repository *worker.ArtifactRepository, signals <-chan os.Signal, ready chan<- struct{}, ) error
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.
func (*GetAction) VersionInfo ¶
func (action *GetAction) VersionInfo() VersionInfo
VersionInfo returns the fetched or cached resource's version and metadata.
type GetStepFactory ¶
type GetStepFactory struct {
ActionsStep
}
func (GetStepFactory) Using ¶
func (s GetStepFactory) Using(repository *worker.ArtifactRepository) Step
type IdentityStep ¶
type IdentityStep struct { }
IdentityStep does nothing
func (IdentityStep) Run ¶
func (IdentityStep) Run(<-chan os.Signal, chan<- struct{}) error
Run does nothing.
func (IdentityStep) Succeeded ¶
func (IdentityStep) Succeeded() bool
type ImageFetchingDelegate ¶
type MergedConfigFetcher ¶
type MergedConfigFetcher struct { A TaskConfigFetcher B TaskConfigFetcher }
MergedConfigFetcher is used to join two config sources together.
func (MergedConfigFetcher) FetchConfig ¶
func (configFetcher MergedConfigFetcher) 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 (MergedConfigFetcher) Warnings ¶
func (configFetcher MergedConfigFetcher) 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 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 StepFactory, secondStep StepFactory) OnFailureStep
OnFailure constructs an OnFailureStep factory.
func (*OnFailureStep) Run ¶
func (o *OnFailureStep) Run(signals <-chan os.Signal, ready chan<- struct{}) 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.
func (OnFailureStep) Using ¶
func (o OnFailureStep) Using(repo *worker.ArtifactRepository) Step
Using constructs an *OnFailureStep.
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 OnSuccess ¶
func OnSuccess(firstStep StepFactory, secondStep StepFactory) OnSuccessStep
OnSuccess constructs an OnSuccessStep factory.
func (*OnSuccessStep) Run ¶
func (o *OnSuccessStep) Run(signals <-chan os.Signal, ready chan<- struct{}) 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.
func (OnSuccessStep) Using ¶
func (o OnSuccessStep) Using(repo *worker.ArtifactRepository) Step
Using constructs an *OnSuccessStep.
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 PutAction ¶
type PutAction struct { Type string Name string Resource string Source creds.Source Params atc.Params Tags atc.Tags // contains filtered or unexported fields }
PutAction produces a resource version using preconfigured params and any data available in the worker.ArtifactRepository.
func NewPutAction ¶
func NewPutAction( resourceType string, name string, resourceName string, source creds.Source, params atc.Params, tags atc.Tags, imageFetchingDelegate ImageFetchingDelegate, resourceFactory resource.ResourceFactory, teamID int, buildID int, planID atc.PlanID, containerMetadata db.ContainerMetadata, stepMetadata StepMetadata, resourceTypes creds.VersionedResourceTypes, ) *PutAction
func (*PutAction) ExitStatus ¶
func (action *PutAction) ExitStatus() ExitStatus
ExitStatus returns exit status of resource put script.
func (*PutAction) Run ¶
func (action *PutAction) Run( logger lager.Logger, repository *worker.ArtifactRepository, signals <-chan os.Signal, ready chan<- struct{}, ) error
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. The PutStep is ready as soon as the resource's script starts, and signals will be forwarded to the script.
func (*PutAction) VersionInfo ¶
func (action *PutAction) VersionInfo() VersionInfo
VersionInfo returns the produced resource's version and metadata.
type PutActionVersionSource ¶
type PutActionVersionSource struct {
Action *PutAction
}
func (*PutActionVersionSource) GetVersion ¶
func (p *PutActionVersionSource) GetVersion() (atc.Version, error)
type PutResourceSource ¶
type PutResourceSource struct {
worker.ArtifactSource
}
func (PutResourceSource) StreamTo ¶
func (source PutResourceSource) StreamTo(dest worker.ArtifactDestination) error
type PutStepFactory ¶
type PutStepFactory struct {
ActionsStep
}
func (PutStepFactory) Using ¶
func (s PutStepFactory) Using(repository *worker.ArtifactRepository) Step
type Retry ¶
type Retry []StepFactory
Retry constructs a Step that will run the steps in order until one of them succeeds.
type RetryStep ¶
RetryStep is a step that will run the steps in order until one of them succeeds.
type StaticConfigFetcher ¶
StaticConfigFetcher represents a statically configured TaskConfig.
func (StaticConfigFetcher) FetchConfig ¶
func (configFetcher StaticConfigFetcher) FetchConfig(*worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig returns the configuration.
func (StaticConfigFetcher) Warnings ¶
func (configFetcher StaticConfigFetcher) Warnings() []string
type StaticVersionSource ¶
func (*StaticVersionSource) GetVersion ¶
func (p *StaticVersionSource) GetVersion() (atc.Version, error)
type Step ¶
type Step interface { // Run is called when it's time to execute the step. It should indicate when // it's ready, and listen for signals at points where the potential time is // unbounded (i.e. running a task or a resource action). // // Steps wrapping other steps should be careful to propagate signals and // indicate that they're ready as soon as their wrapped steps are ready. // // Steps should return ErrInterrupted if they received a signal that caused // them to stop. // // Steps must be idempotent. Each step is responsible for handling its own // idempotency; usually this is done by saving off "checkpoints" in some way // that can be checked again if the step starts running again from the start. // For example, by having the ID for a container be deterministic and unique // for each step, and checking for properties on the container to determine // how far the step got. ifrit.Runner // 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.
type StepFactory ¶
type StepFactory interface {
Using(*worker.ArtifactRepository) Step
}
StepFactory constructs a step. The previous step and source repository are provided.
Some steps, i.e. DependentGetStep, use information from the previous step to determine how to run. TODO: Remove Step in prev
type StepMetadata ¶
type StepMetadata interface {
Env() []string
}
StepMetadata is used to inject metadata to make available to the step when it's running.
type TaskAction ¶
type TaskAction struct {
// contains filtered or unexported fields
}
TaskAction executes a TaskConfig, whose inputs will be fetched from the worker.ArtifactRepository and outputs will be added to the worker.ArtifactRepository.
func NewTaskAction ¶
func NewTaskAction( privileged Privileged, configSource TaskConfigSource, tags atc.Tags, inputMapping map[string]string, outputMapping map[string]string, artifactsRoot string, imageArtifactName string, buildEventsDelegate TaskBuildEventsDelegate, imageFetchingDelegate ImageFetchingDelegate, workerPool worker.Client, teamID int, buildID int, jobID int, stepName string, planID atc.PlanID, containerMetadata db.ContainerMetadata, resourceTypes creds.VersionedResourceTypes, variables creds.Variables, ) *TaskAction
func (*TaskAction) ExitStatus ¶
func (action *TaskAction) ExitStatus() ExitStatus
ExitStatus returns exit status of task script.
func (*TaskAction) Run ¶
func (action *TaskAction) Run( logger lager.Logger, repository *worker.ArtifactRepository, signals <-chan os.Signal, ready chan<- struct{}, ) error
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 satisfies, the task's script will be executed, and the RunStep indicates that it's ready, and any signals will be forwarded to the script.
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 TaskBuildEventsDelegate ¶
type TaskBuildEventsDelegate interface { Initializing(lager.Logger, atc.TaskConfig) Starting(lager.Logger, atc.TaskConfig) }
type TaskConfigFetcher ¶
type TaskConfigFetcher 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 }
TaskConfigFetcher is used to determine a Task step's TaskConfig.
type TaskConfigSource ¶
type TaskConfigSource interface {
GetTaskConfig() (atc.TaskConfig, error)
}
type TaskImageSourceParametersError ¶
type TaskImageSourceParametersError struct {
Err error
}
func (TaskImageSourceParametersError) Error ¶
func (err TaskImageSourceParametersError) Error() string
type TaskStepFactory ¶
type TaskStepFactory struct {
ActionsStep
}
func (TaskStepFactory) Using ¶
func (s TaskStepFactory) Using(repository *worker.ArtifactRepository) Step
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 StepFactory, duration string, clock clock.Clock, ) TimeoutStep
Timeout constructs a TimeoutStep factory.
func (*TimeoutStep) Run ¶
func (ts *TimeoutStep) Run(signals <-chan os.Signal, ready chan<- struct{}) 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.
func (TimeoutStep) Using ¶
func (ts TimeoutStep) Using(repo *worker.ArtifactRepository) Step
Using constructs a *TimeoutStep.
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 ValidatingConfigFetcher ¶
type ValidatingConfigFetcher struct {
ConfigFetcher TaskConfigFetcher
}
ValidatingConfigFetcher delegates to another ConfigFetcher, and validates its task config.
func (ValidatingConfigFetcher) FetchConfig ¶
func (configFetcher ValidatingConfigFetcher) FetchConfig(source *worker.ArtifactRepository) (atc.TaskConfig, error)
FetchConfig fetches the config using the underlying ConfigFetcher, and checks that it's valid.
func (ValidatingConfigFetcher) Warnings ¶
func (configFetcher ValidatingConfigFetcher) 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 ¶
Source Files ¶
- actions_step.go
- aggregate.go
- ensure_step.go
- errors.go
- factory.go
- fetch_config_action.go
- file_read_closer.go
- garden_factory.go
- get_action.go
- identity_step.go
- on_failure.go
- on_success.go
- put_action.go
- retry_step.go
- step.go
- task_action.go
- task_config_fetcher.go
- timeout_step.go
- try_step.go
- version_source.go