Documentation
¶
Index ¶
- func UserCacheDir() (string, error)
- type CacheKeyer
- type Coordinator
- type ExecutionCache
- type ExecutionDiskCache
- func (c ExecutionDiskCache) Clear(ctx context.Context, key CacheKeyer) error
- func (c ExecutionDiskCache) Get(ctx context.Context, key CacheKeyer) (executionResult, bool, error)
- func (c ExecutionDiskCache) GetStepResult(ctx context.Context, key CacheKeyer) (stepExecutionResult, bool, error)
- func (c ExecutionDiskCache) Set(ctx context.Context, key CacheKeyer, result executionResult) error
- func (c ExecutionDiskCache) SetStepResult(ctx context.Context, key CacheKeyer, result stepExecutionResult) error
- type ExecutionNoOpCache
- func (ExecutionNoOpCache) Clear(ctx context.Context, key CacheKeyer) error
- func (ExecutionNoOpCache) Get(ctx context.Context, key CacheKeyer) (result executionResult, found bool, err error)
- func (ExecutionNoOpCache) GetStepResult(ctx context.Context, key CacheKeyer) (stepExecutionResult, bool, error)
- func (ExecutionNoOpCache) Set(ctx context.Context, key CacheKeyer, result executionResult) error
- func (ExecutionNoOpCache) SetStepResult(ctx context.Context, key CacheKeyer, result stepExecutionResult) error
- type NewCoordinatorOpts
- type NoopStepOutputWriter
- type NoopStepsExecUI
- func (noop NoopStepsExecUI) ArchiveDownloadFinished(error)
- func (noop NoopStepsExecUI) ArchiveDownloadStarted()
- func (noop NoopStepsExecUI) CalculatingDiffFinished()
- func (noop NoopStepsExecUI) CalculatingDiffStarted()
- 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 StepOutputWriter
- type StepsCacheKey
- type StepsExecutionUI
- type Task
- type TaskCacheKey
- type TaskExecutionErr
- type TaskExecutionUI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UserCacheDir ¶
Types ¶
type CacheKeyer ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinates coordinates the execution of Tasks. It makes use of an executor, checks the ExecutionCache whether execution is necessary, builds batcheslib.ChangesetSpecs out of the executionResults.
func NewCoordinator ¶
func NewCoordinator(opts NewCoordinatorOpts) *Coordinator
func (*Coordinator) CheckCache ¶
func (c *Coordinator) CheckCache(ctx context.Context, 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) Execute ¶
func (c *Coordinator) Execute(ctx context.Context, tasks []*Task, spec *batcheslib.BatchSpec, ui TaskExecutionUI) ([]*batcheslib.ChangesetSpec, []string, error)
Execute executes the given Tasks and the importChangeset statements in the given spec. It regularly calls the executionProgressPrinter with the current TaskStatuses.
type ExecutionCache ¶
type ExecutionCache interface {
Get(ctx context.Context, key CacheKeyer) (result executionResult, found bool, err error)
Set(ctx context.Context, key CacheKeyer, result executionResult) error
GetStepResult(ctx context.Context, key CacheKeyer) (result stepExecutionResult, found bool, err error)
SetStepResult(ctx context.Context, key CacheKeyer, result stepExecutionResult) error
Clear(ctx context.Context, key CacheKeyer) error
}
func NewCache ¶
func NewCache(dir string) ExecutionCache
type ExecutionDiskCache ¶
type ExecutionDiskCache struct {
Dir string
}
func (ExecutionDiskCache) Clear ¶
func (c ExecutionDiskCache) Clear(ctx context.Context, key CacheKeyer) error
func (ExecutionDiskCache) Get ¶
func (c ExecutionDiskCache) Get(ctx context.Context, key CacheKeyer) (executionResult, bool, error)
func (ExecutionDiskCache) GetStepResult ¶
func (c ExecutionDiskCache) GetStepResult(ctx context.Context, key CacheKeyer) (stepExecutionResult, bool, error)
func (ExecutionDiskCache) Set ¶
func (c ExecutionDiskCache) Set(ctx context.Context, key CacheKeyer, result executionResult) error
func (ExecutionDiskCache) SetStepResult ¶
func (c ExecutionDiskCache) SetStepResult(ctx context.Context, key CacheKeyer, result stepExecutionResult) error
type ExecutionNoOpCache ¶
type ExecutionNoOpCache struct{}
ExecutionNoOpCache is an implementation of ExecutionCache that does not store or retrieve cache entries.
func (ExecutionNoOpCache) Clear ¶
func (ExecutionNoOpCache) Clear(ctx context.Context, key CacheKeyer) error
func (ExecutionNoOpCache) Get ¶
func (ExecutionNoOpCache) Get(ctx context.Context, key CacheKeyer) (result executionResult, found bool, err error)
func (ExecutionNoOpCache) GetStepResult ¶
func (ExecutionNoOpCache) GetStepResult(ctx context.Context, key CacheKeyer) (stepExecutionResult, bool, error)
func (ExecutionNoOpCache) Set ¶
func (ExecutionNoOpCache) Set(ctx context.Context, key CacheKeyer, result executionResult) error
func (ExecutionNoOpCache) SetStepResult ¶
func (ExecutionNoOpCache) SetStepResult(ctx context.Context, key CacheKeyer, result stepExecutionResult) error
type NewCoordinatorOpts ¶
type NewCoordinatorOpts struct {
// Dependencies
ResolveRepoName repoNameResolver
EnsureImage imageEnsurer
Creator workspace.Creator
Client api.Client
// TODO: We could probably have a wrapper around flags and features,
// something like ExecutionArgs, that we can pass around
CacheDir string
ClearCache bool
SkipErrors bool
// Used by createChangesetSpecs
Features batches.FeatureFlags
CleanArchives bool
Parallelism int
Timeout time.Duration
KeepLogs bool
TempDir string
}
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) CalculatingDiffFinished ¶
func (noop NoopStepsExecUI) CalculatingDiffFinished()
func (NoopStepsExecUI) CalculatingDiffStarted ¶
func (noop NoopStepsExecUI) CalculatingDiffStarted()
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 StepOutputWriter ¶
type StepsCacheKey ¶
StepsCacheKey implements the CacheKeyer interface for a Task and a *subset* of its Steps, up to and including the step with index StepIndex in Task.Steps.
func (StepsCacheKey) Key ¶
func (key StepsCacheKey) Key() (string, error)
Key converts the key into a string form that can be used to uniquely identify the cache key in a more concise form than the entire Task.
func (StepsCacheKey) Slug ¶
func (key StepsCacheKey) Slug() string
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
CalculatingDiffStarted()
CalculatingDiffFinished()
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
// TODO(mrnugget): this should just be a single BatchSpec field instead, if
// we can make it work with caching
BatchChangeAttributes *template.BatchChangeAttributes `json:"-"`
Template *batcheslib.ChangesetTemplate `json:"-"`
TransformChanges *batcheslib.TransformChanges `json:"-"`
Archive repozip.Archive `json:"-"`
CachedResultFound bool `json:"-"`
CachedResult stepExecutionResult `json:"-"`
}
func (*Task) ArchivePathToFetch ¶
type TaskCacheKey ¶
type TaskCacheKey struct {
*Task
}
TaskCacheKey implements the CacheKeyer interface for a Task and all its Steps.
func (TaskCacheKey) Key ¶
func (key TaskCacheKey) Key() (string, error)
Key converts the key into a string form that can be used to uniquely identify the cache key in a more concise form than the entire Task.
func (TaskCacheKey) Slug ¶
func (key TaskCacheKey) Slug() string
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
}