refactor: rename Runner.Execute > Runner.RunWorkflow for consistency
This commit is contained in:
parent
da6dbee691
commit
0ad6e5b044
2 changed files with 20 additions and 20 deletions
|
@ -36,7 +36,7 @@ func ExecuteWorkflow(configuration Configuration, workflowFile string) error {
|
||||||
return errors.New("Jobs encountered errors.")
|
return errors.New("Jobs encountered errors.")
|
||||||
}
|
}
|
||||||
|
|
||||||
taskResult := runnerInstance.Execute(*workflow)
|
taskResult := runnerInstance.RunWorkflow(*workflow)
|
||||||
|
|
||||||
if !taskResult.HasError() {
|
if !taskResult.HasError() {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (r *Runner) GetTask(taskId string) *Task {
|
||||||
// This is the high-level call that will set up the container
|
// This is the high-level call that will set up the container
|
||||||
// that the jobs will be executed in, run the jobs's steps and
|
// that the jobs will be executed in, run the jobs's steps and
|
||||||
// tear down the container once no longer useful.
|
// tear down the container once no longer useful.
|
||||||
func (r *Runner) Execute(workflow workflow.Workflow) Task {
|
func (r *Runner) RunWorkflow(workflow workflow.Workflow) Task {
|
||||||
log.Printf("Executing workflow: %s", workflow.SourcePath)
|
log.Printf("Executing workflow: %s", workflow.SourcePath)
|
||||||
task := r.GetTask(r.AddTask())
|
task := r.GetTask(r.AddTask())
|
||||||
|
|
||||||
|
@ -114,6 +114,24 @@ func (r *Runner) Execute(workflow workflow.Workflow) Task {
|
||||||
return *task
|
return *task
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Executes a command within the given container.
|
||||||
|
//
|
||||||
|
// If the command raises an error while in the container or fails to run
|
||||||
|
// the command at all, an error is returned, otherwise nil.
|
||||||
|
func (r *Runner) RunCommandInContainer(containerId string, command string) error {
|
||||||
|
result := r.Driver.Exec(containerId, command)
|
||||||
|
|
||||||
|
if result.Error != nil {
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.ExitCode != 0 {
|
||||||
|
return errors.New(fmt.Sprintf("Command returned a non-zero exit code (%d).", result.ExitCode))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Executes a job within a container.
|
// Executes a job within a container.
|
||||||
//
|
//
|
||||||
// The container is started before the job steps are run and cleaned up after.
|
// The container is started before the job steps are run and cleaned up after.
|
||||||
|
@ -136,21 +154,3 @@ func (r *Runner) RunJobInContainer(imageUri string, containerId string, job work
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executes a command within the given container.
|
|
||||||
//
|
|
||||||
// If the command raises an error while in the container or fails to run
|
|
||||||
// the command at all, an error is returned, otherwise nil.
|
|
||||||
func (r *Runner) RunCommandInContainer(containerId string, command string) error {
|
|
||||||
result := r.Driver.Exec(containerId, command)
|
|
||||||
|
|
||||||
if result.Error != nil {
|
|
||||||
return result.Error
|
|
||||||
}
|
|
||||||
|
|
||||||
if result.ExitCode != 0 {
|
|
||||||
return errors.New(fmt.Sprintf("Command returned a non-zero exit code (%d).", result.ExitCode))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue