@@ -200,20 +200,20 @@ func (svc *Service) NewRepoFetcher(dir string, cleanArchives bool) RepoFetcher {
200200}
201201
202202func (svc * Service ) NewWorkspaceCreator (ctx context.Context , cacheDir , tempDir string , steps []Step ) WorkspaceCreator {
203- var workspace workspaceCreatorType
203+ if svc .workspaceCreatorType (ctx , steps ) == workspaceCreatorVolume {
204+ return & dockerVolumeWorkspaceCreator {tempDir : tempDir }
205+ }
206+ return & dockerBindWorkspaceCreator {dir : cacheDir }
207+ }
204208
209+ func (svc * Service ) workspaceCreatorType (ctx context.Context , steps []Step ) workspaceCreatorType {
205210 if svc .workspace == "volume" {
206- workspace = workspaceCreatorVolume
211+ return workspaceCreatorVolume
207212 } else if svc .workspace == "bind" {
208- workspace = workspaceCreatorBind
209- } else {
210- workspace = bestWorkspaceCreator (ctx , steps )
213+ return workspaceCreatorBind
211214 }
212215
213- if workspace == workspaceCreatorVolume {
214- return & dockerVolumeWorkspaceCreator {tempDir : tempDir }
215- }
216- return & dockerBindWorkspaceCreator {dir : cacheDir }
216+ return bestWorkspaceCreator (ctx , steps )
217217}
218218
219219// SetDockerImages updates the steps within the campaign spec to include the
@@ -236,9 +236,12 @@ func (svc *Service) SetDockerImages(ctx context.Context, spec *CampaignSpec, pro
236236 progress (float64 (i ) / float64 (total ))
237237 }
238238
239- // We also need to ensure we have our own utility images available.
240- if err := svc .imageCache .Get (dockerVolumeWorkspaceImage ).Ensure (ctx ); err != nil {
241- return errors .Wrapf (err , "pulling image %q" , dockerVolumeWorkspaceImage )
239+ // We also need to ensure we have our own utility images available, if
240+ // necessary.
241+ if svc .workspaceCreatorType (ctx , spec .Steps ) == workspaceCreatorVolume {
242+ if err := svc .imageCache .Get (dockerVolumeWorkspaceImage ).Ensure (ctx ); err != nil {
243+ return errors .Wrapf (err , "pulling image %q" , dockerVolumeWorkspaceImage )
244+ }
242245 }
243246
244247 progress (1 )
0 commit comments