Skip to content

Commit 9464877

Browse files
authored
campaigns: only pull the Docker image in volume mode (#477)
1 parent 1d4a792 commit 9464877

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ All notable changes to `src-cli` are documented in this file.
1515

1616
### Changed
1717

18+
- The volume workspace Docker image is now only pulled if the volume workspace mode is in use. [#477](https://github.com/sourcegraph/src-cli/pull/477)
19+
1820
### Fixed
1921

2022
### Removed

internal/campaigns/service.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,20 @@ func (svc *Service) NewRepoFetcher(dir string, cleanArchives bool) RepoFetcher {
200200
}
201201

202202
func (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

Comments
 (0)