Add flag to skip pulling images already present

This commit is contained in:
Marc Campbell
2019-02-17 21:40:22 -08:00
parent 3a4de2d215
commit 7fadbdb6e8
5 changed files with 96 additions and 4 deletions

View File

@@ -43,6 +43,7 @@ type RunnerConfig struct {
EventName string // name of event to run
EventPath string // path to JSON file to use for event.json in containers, relative to WorkingDir
ReuseContainers bool // reuse containers to maintain state
ForcePull bool // force pulling of the image, if already present
}
type environmentApplier interface {

View File

@@ -49,10 +49,25 @@ func (runner *runnerImpl) addImageExecutor(action *model.Action, executors *[]co
case *model.UsesDockerImage:
image = uses.Image
*executors = append(*executors, container.NewDockerPullExecutor(container.NewDockerPullExecutorInput{
DockerExecutorInput: in,
Image: image,
}))
pull := runner.config.ForcePull
if !pull {
imageExists, err := container.ImageExistsLocally(runner.config.Ctx, image)
if err != nil {
return "", fmt.Errorf("unable to determine if image already exists for image %q", image)
}
if imageExists {
pull = false
}
}
if pull {
*executors = append(*executors, container.NewDockerPullExecutor(container.NewDockerPullExecutorInput{
DockerExecutorInput: in,
Image: image,
}))
}
case *model.UsesPath:
contextDir := filepath.Join(runner.config.WorkingDir, uses.String())