refactor: rename Runner.Execute > Runner.RunWorkflow for consistency

This commit is contained in:
Marc 2024-08-02 19:40:06 -04:00
parent da6dbee691
commit 0ad6e5b044
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 20 additions and 20 deletions

View file

@ -36,7 +36,7 @@ func ExecuteWorkflow(configuration Configuration, workflowFile string) error {
return errors.New("Jobs encountered errors.")
}
taskResult := runnerInstance.Execute(*workflow)
taskResult := runnerInstance.RunWorkflow(*workflow)
if !taskResult.HasError() {
return nil

View file

@ -83,7 +83,7 @@ func (r *Runner) GetTask(taskId string) *Task {
// 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
// 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)
task := r.GetTask(r.AddTask())
@ -114,6 +114,24 @@ func (r *Runner) Execute(workflow workflow.Workflow) 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.
//
// 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
}
// 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
}