refactor: remove pull indirection, call driver directly
This commit is contained in:
parent
2e31942b6d
commit
da6dbee691
2 changed files with 1 additions and 26 deletions
|
@ -96,7 +96,7 @@ func (r *Runner) Execute(workflow workflow.Workflow) Task {
|
|||
|
||||
log.Printf("Using image %s (label: %s)", runnerImage, job.RunsOn)
|
||||
|
||||
if pullError := r.PullContainer(runnerImage); pullError != nil {
|
||||
if pullError := r.Driver.Pull(runnerImage); pullError != nil {
|
||||
jobContext.SetStatus("failed").SetError(pullError)
|
||||
continue
|
||||
}
|
||||
|
@ -137,11 +137,6 @@ func (r *Runner) RunJobInContainer(imageUri string, containerId string, job work
|
|||
return nil
|
||||
}
|
||||
|
||||
// Pulls the container from the registry provided its image uri.
|
||||
func (r *Runner) PullContainer(uri string) error {
|
||||
return r.Driver.Pull(uri)
|
||||
}
|
||||
|
||||
// Executes a command within the given container.
|
||||
//
|
||||
// If the command raises an error while in the container or fails to run
|
||||
|
|
|
@ -3,7 +3,6 @@ package runner
|
|||
import (
|
||||
"errors"
|
||||
workflow "runner/internal/workflow"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -111,22 +110,3 @@ func TestRunJobInContainerSchedulesStoppingContainers(t *testing.T) {
|
|||
t.Errorf("Expected 1 deferred task, found %d instead.", len(runner.deferred))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerPullContainerCallsDriverPull(t *testing.T) {
|
||||
mockDriver := NewMockDriver()
|
||||
runner := Runner{
|
||||
Driver: &mockDriver,
|
||||
}
|
||||
|
||||
runner.PullContainer("test-image")
|
||||
|
||||
if len(mockDriver.calls) != 1 {
|
||||
t.Error("Expected pull to have been called.")
|
||||
}
|
||||
|
||||
expectedArgs := []string{"test-image"}
|
||||
actualArgs := mockDriver.calls["Pull"][0].args
|
||||
if !slices.Equal(actualArgs, expectedArgs) {
|
||||
t.Errorf("Expected call args to be %#v, got %#v instead.", expectedArgs, actualArgs)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue