Documentation ¶
Index ¶
- func NewDiskCache(dir string) cache.Cache
- func NewExecutor(opts NewExecutorOpts) *executor
- func RunSteps(ctx context.Context, opts *RunStepsOpts) (stepResults []execution.AfterStepResult, err error)
- type Coordinator
- func (c *Coordinator) CheckCache(ctx context.Context, batchSpec *batcheslib.BatchSpec, tasks []*Task) (uncached []*Task, specs []*batcheslib.ChangesetSpec, err error)
- func (c *Coordinator) ClearCache(ctx context.Context, tasks []*Task) error
- func (c *Coordinator) ExecuteAndBuildSpecs(ctx context.Context, batchSpec *batcheslib.BatchSpec, tasks []*Task, ...) ([]*batcheslib.ChangesetSpec, []string, error)
- type ExecutionDiskCache
- type ExecutionNoOpCache
- type NewCoordinatorOpts
- type NewExecutorOpts
- type NoopStepOutputWriter
- type NoopStepsExecUI
- func (noop NoopStepsExecUI) ArchiveDownloadFinished(error)
- func (noop NoopStepsExecUI) ArchiveDownloadStarted()
- func (noop NoopStepsExecUI) SkippingStepsUpto(startStep int)
- func (noop NoopStepsExecUI) StepFailed(idx int, err error, exitCode int)
- func (noop NoopStepsExecUI) StepFinished(idx int, diff []byte, changes git.Changes, outputs map[string]interface{})
- func (noop NoopStepsExecUI) StepOutputWriter(ctx context.Context, task *Task, step int) StepOutputWriter
- func (noop NoopStepsExecUI) StepPreparingFailed(step int, err error)
- func (noop NoopStepsExecUI) StepPreparingStart(step int)
- func (noop NoopStepsExecUI) StepPreparingSuccess(step int)
- func (noop NoopStepsExecUI) StepSkipped(step int)
- func (noop NoopStepsExecUI) StepStarted(step int, runScript string, env map[string]string)
- func (noop NoopStepsExecUI) WorkspaceInitializationFinished()
- func (noop NoopStepsExecUI) WorkspaceInitializationStarted()
- type RunStepsOpts
- type StepOutputWriter
- type StepsExecutionUI
- type Task
- type TaskExecutionErr
- type TaskExecutionUI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDiskCache ¶
func NewExecutor ¶
func NewExecutor(opts NewExecutorOpts) *executor
func RunSteps ¶
func RunSteps(ctx context.Context, opts *RunStepsOpts) (stepResults []execution.AfterStepResult, err error)
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator coordinates the execution of Tasks. It makes use of an executor, checks the ExecutionCache whether execution is necessary, and builds batcheslib.ChangesetSpecs out of the executionResults.
func NewCoordinator ¶
func NewCoordinator(opts NewCoordinatorOpts) *Coordinator
func (*Coordinator) CheckCache ¶
func (c *Coordinator) CheckCache(ctx context.Context, batchSpec *batcheslib.BatchSpec, tasks []*Task) (uncached []*Task, specs []*batcheslib.ChangesetSpec, err error)
CheckCache checks whether the internal ExecutionCache contains ChangesetSpecs for the given Tasks. If cached ChangesetSpecs exist, those are returned, otherwise the Task, to be executed later.
func (*Coordinator) ClearCache ¶
func (c *Coordinator) ClearCache(ctx context.Context, tasks []*Task) error
func (*Coordinator) ExecuteAndBuildSpecs ¶
func (c *Coordinator) ExecuteAndBuildSpecs(ctx context.Context, batchSpec *batcheslib.BatchSpec, tasks []*Task, ui TaskExecutionUI) ([]*batcheslib.ChangesetSpec, []string, error)
ExecuteAndBuildSpecs executes the given tasks and builds changeset specs for the results. It calls the ui on updates.
type ExecutionDiskCache ¶
type ExecutionDiskCache struct {
Dir string
}
func (ExecutionDiskCache) Get ¶
func (c ExecutionDiskCache) Get(ctx context.Context, key cache.Keyer) (execution.AfterStepResult, bool, error)
func (ExecutionDiskCache) Set ¶
func (c ExecutionDiskCache) Set(ctx context.Context, key cache.Keyer, result execution.AfterStepResult) error
type ExecutionNoOpCache ¶
type ExecutionNoOpCache struct{}
ExecutionNoOpCache is an implementation of ExecutionCache that does not store or retrieve cache entries.
func (ExecutionNoOpCache) Get ¶
func (ExecutionNoOpCache) Get(ctx context.Context, key cache.Keyer) (execution.AfterStepResult, bool, error)
func (ExecutionNoOpCache) Set ¶
func (ExecutionNoOpCache) Set(ctx context.Context, key cache.Keyer, result execution.AfterStepResult) error
type NewCoordinatorOpts ¶
type NewCoordinatorOpts struct { ExecOpts NewExecutorOpts Cache cache.Cache Logger log.LogManager GlobalEnv []string BinaryDiffs bool IsRemote bool }
type NewExecutorOpts ¶
type NewExecutorOpts struct { // Dependencies Creator workspace.Creator RepoArchiveRegistry repozip.ArchiveRegistry EnsureImage imageEnsurer Logger log.LogManager // Config Parallelism int Timeout time.Duration WorkingDirectory string TempDir string IsRemote bool GlobalEnv []string ForceRoot bool BinaryDiffs bool }
type NoopStepOutputWriter ¶
type NoopStepOutputWriter struct{}
func (NoopStepOutputWriter) Close ¶
func (noop NoopStepOutputWriter) Close() error
func (NoopStepOutputWriter) StderrWriter ¶
func (noop NoopStepOutputWriter) StderrWriter() io.Writer
func (NoopStepOutputWriter) StdoutWriter ¶
func (noop NoopStepOutputWriter) StdoutWriter() io.Writer
type NoopStepsExecUI ¶
type NoopStepsExecUI struct{}
NoopStepsExecUI is an implementation of StepsExecutionUI that does nothing.
func (NoopStepsExecUI) ArchiveDownloadFinished ¶
func (noop NoopStepsExecUI) ArchiveDownloadFinished(error)
func (NoopStepsExecUI) ArchiveDownloadStarted ¶
func (noop NoopStepsExecUI) ArchiveDownloadStarted()
func (NoopStepsExecUI) SkippingStepsUpto ¶
func (noop NoopStepsExecUI) SkippingStepsUpto(startStep int)
func (NoopStepsExecUI) StepFailed ¶
func (noop NoopStepsExecUI) StepFailed(idx int, err error, exitCode int)
func (NoopStepsExecUI) StepFinished ¶
func (NoopStepsExecUI) StepOutputWriter ¶
func (noop NoopStepsExecUI) StepOutputWriter(ctx context.Context, task *Task, step int) StepOutputWriter
func (NoopStepsExecUI) StepPreparingFailed ¶
func (noop NoopStepsExecUI) StepPreparingFailed(step int, err error)
func (NoopStepsExecUI) StepPreparingStart ¶
func (noop NoopStepsExecUI) StepPreparingStart(step int)
func (NoopStepsExecUI) StepPreparingSuccess ¶
func (noop NoopStepsExecUI) StepPreparingSuccess(step int)
func (NoopStepsExecUI) StepSkipped ¶
func (noop NoopStepsExecUI) StepSkipped(step int)
func (NoopStepsExecUI) StepStarted ¶
func (noop NoopStepsExecUI) StepStarted(step int, runScript string, env map[string]string)
func (NoopStepsExecUI) WorkspaceInitializationFinished ¶
func (noop NoopStepsExecUI) WorkspaceInitializationFinished()
func (NoopStepsExecUI) WorkspaceInitializationStarted ¶
func (noop NoopStepsExecUI) WorkspaceInitializationStarted()
type RunStepsOpts ¶
type RunStepsOpts struct { // WC is the workspace creator to use. It will be called at the beginning of // runSteps to prepare the workspace for execution. WC workspace.Creator // EnsureImage is called in runSteps to make sure the used image has been // pulled from the registry. EnsureImage imageEnsurer // Task is the definition of the workspace execution. Task *Task // TempDir points to where temporary files of the execution should live at. TempDir string // WorkingDirectory points to where the workspace files should live at. WorkingDirectory string // Timeout sets the deadline for the execution context. When exceeded, // execution will stop and an error is returned. Timeout time.Duration // RepoArchive is the repo archive to be used for creating the workspace. RepoArchive repozip.Archive Logger log.TaskLogger UI StepsExecutionUI // GlobalEnv is the os.Environ() for the execution. We don't read from os.Environ() // directly to allow injecting variables and hiding others. GlobalEnv []string // ForceRoot forces Docker containers to be run as root:root, rather than // whatever the image's default user and group are. ForceRoot bool BinaryDiffs bool }
type StepOutputWriter ¶
type StepsExecutionUI ¶
type StepsExecutionUI interface { ArchiveDownloadStarted() ArchiveDownloadFinished(error) WorkspaceInitializationStarted() WorkspaceInitializationFinished() SkippingStepsUpto(int) StepSkipped(int) StepPreparingStart(int) StepPreparingSuccess(int) StepPreparingFailed(int, error) StepStarted(stepIdx int, runScript string, env map[string]string) StepOutputWriter(context.Context, *Task, int) StepOutputWriter StepFinished(idx int, diff []byte, changes git.Changes, outputs map[string]interface{}) StepFailed(idx int, err error, exitCode int) }
type Task ¶
type Task struct { Repository *graphql.Repository // Path is the folder relative to the repository's root in which the steps // should be executed. "" means root. Path string // OnlyFetchWorkspace determines whether the repository archive contains // the complete repository or just the files in Path (and additional files, // see RepoFetcher). // If Path is "" then this setting has no effect. OnlyFetchWorkspace bool Steps []batcheslib.Step BatchChangeAttributes *template.BatchChangeAttributes // CachedStepResultFound is true when a partial execution result was found in the cache. // When this field is true, CachedStepResult is also populated. CachedStepResultFound bool CachedStepResult execution.AfterStepResult }
func (*Task) ArchivePathToFetch ¶
type TaskExecutionErr ¶
func (TaskExecutionErr) Cause ¶
func (e TaskExecutionErr) Cause() error
func (TaskExecutionErr) Error ¶
func (e TaskExecutionErr) Error() string
func (TaskExecutionErr) StatusText ¶
func (e TaskExecutionErr) StatusText() string
type TaskExecutionUI ¶
type TaskExecutionUI interface { Start([]*Task) Success() Failed(err error) TaskStarted(*Task) TaskFinished(*Task, error) TaskChangesetSpecsBuilt(*Task, []*batcheslib.ChangesetSpec) StepsExecutionUI(*Task) StepsExecutionUI }