Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ All notable changes to `src-cli` are documented in this file.

### Fixed

- Fixes an issue where src-cli would panic when importing existing changesets.

### Removed

## 3.31.1
Expand Down
26 changes: 15 additions & 11 deletions cmd/src/batch_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,26 @@ func executeBatchSpec(ctx context.Context, opts executeBatchSpecOpts) (err error
}
opts.ui.ResolvingNamespaceSuccess(namespace)

opts.ui.PreparingContainerImages()
images, err := svc.EnsureDockerImages(ctx, batchSpec, opts.ui.PreparingContainerImagesProgress)
if err != nil {
return err
}
opts.ui.PreparingContainerImagesSuccess()
var workspaceCreator workspace.Creator

opts.ui.DeterminingWorkspaceCreatorType()
workspaceCreator := workspace.NewCreator(ctx, opts.flags.workspace, opts.flags.cacheDir, opts.flags.tempDir, images)
if workspaceCreator.Type() == workspace.CreatorTypeVolume {
_, err = svc.EnsureImage(ctx, workspace.DockerVolumeWorkspaceImage)
if svc.HasDockerImages(batchSpec) {
opts.ui.PreparingContainerImages()
images, err := svc.EnsureDockerImages(ctx, batchSpec, opts.ui.PreparingContainerImagesProgress)
if err != nil {
return err
}
opts.ui.PreparingContainerImagesSuccess()

opts.ui.DeterminingWorkspaceCreatorType()
workspaceCreator = workspace.NewCreator(ctx, opts.flags.workspace, opts.flags.cacheDir, opts.flags.tempDir, images)
if workspaceCreator.Type() == workspace.CreatorTypeVolume {
_, err = svc.EnsureImage(ctx, workspace.DockerVolumeWorkspaceImage)
if err != nil {
return err
}
}
opts.ui.DeterminingWorkspaceCreatorTypeSuccess(workspaceCreator.Type())
}
opts.ui.DeterminingWorkspaceCreatorTypeSuccess(workspaceCreator.Type())

opts.ui.ResolvingRepositories()
repos, err := svc.ResolveRepositories(ctx, batchSpec)
Expand Down
26 changes: 15 additions & 11 deletions cmd/src/batch_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,26 @@ func executeBatchSpecInWorkspaces(ctx context.Context, opts executeBatchSpecOpts
}
opts.ui.ParsingBatchSpecSuccess()

opts.ui.PreparingContainerImages()
images, err := svc.EnsureDockerImages(ctx, batchSpec, opts.ui.PreparingContainerImagesProgress)
if err != nil {
return err
}
opts.ui.PreparingContainerImagesSuccess()
var workspaceCreator workspace.Creator

opts.ui.DeterminingWorkspaceCreatorType()
workspaceCreator := workspace.NewCreator(ctx, opts.flags.workspace, opts.flags.cacheDir, opts.flags.tempDir, images)
if workspaceCreator.Type() == workspace.CreatorTypeVolume {
_, err = svc.EnsureImage(ctx, workspace.DockerVolumeWorkspaceImage)
if svc.HasDockerImages(batchSpec) {
opts.ui.PreparingContainerImages()
images, err := svc.EnsureDockerImages(ctx, batchSpec, opts.ui.PreparingContainerImagesProgress)
if err != nil {
return err
}
opts.ui.PreparingContainerImagesSuccess()

opts.ui.DeterminingWorkspaceCreatorType()
workspaceCreator = workspace.NewCreator(ctx, opts.flags.workspace, opts.flags.cacheDir, opts.flags.tempDir, images)
if workspaceCreator.Type() == workspace.CreatorTypeVolume {
_, err = svc.EnsureImage(ctx, workspace.DockerVolumeWorkspaceImage)
if err != nil {
return err
}
}
opts.ui.DeterminingWorkspaceCreatorTypeSuccess(workspaceCreator.Type())
}
opts.ui.DeterminingWorkspaceCreatorTypeSuccess(workspaceCreator.Type())

// EXECUTION OF TASKS
coord := svc.NewCoordinator(executor.NewCoordinatorOpts{
Expand Down
4 changes: 4 additions & 0 deletions internal/batches/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func (svc *Service) EnsureDockerImages(ctx context.Context, spec *batcheslib.Bat
return images, nil
}

func (svc *Service) HasDockerImages(spec *batcheslib.BatchSpec) bool {
return len(spec.Steps) > 0
}

func (svc *Service) EnsureImage(ctx context.Context, name string) (docker.Image, error) {
img := svc.imageCache.Get(name)

Expand Down