From b31b4bf099a0365a01b4cee779f0ae56a0a6778c Mon Sep 17 00:00:00 2001 From: Ryan Sullivan Date: Wed, 24 Oct 2018 00:48:10 -0400 Subject: [PATCH] Add docker pull images to main command batch array. Among other cleanup --- cmd/drone-docker/main.go | 2 +- docker.go | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index 7028cf8..89cc480 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -153,7 +153,7 @@ func main() { }, cli.StringSliceFlag{ Name: "cache-from", - Usage: "cache from", + Usage: "images to consider as cache sources", EnvVar: "PLUGIN_CACHE_FROM", }, cli.BoolFlag{ diff --git a/docker.go b/docker.go index 0a3cfa5..8cea3fc 100644 --- a/docker.go +++ b/docker.go @@ -105,15 +105,6 @@ func (p Plugin) Exec() error { fmt.Println("Registry credentials not provided. Guest mode enabled.") } - // pre-pull cache image - for _, img := range p.Build.CacheFrom { - cmd := commandPull(img) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - trace(cmd) - cmd.Run() - } - if p.Build.Squash && !p.Daemon.Experimental { fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...") p.Build.Squash = false @@ -126,6 +117,11 @@ func (p Plugin) Exec() error { cmds = append(cmds, commandVersion()) // docker version cmds = append(cmds, commandInfo()) // docker info + // pre-pull cache images + for _, img := range p.Build.CacheFrom { + cmds = append(cmds, commandPull(img)) + } + cmds = append(cmds, commandBuild(p.Build)) // docker build for _, tag := range p.Build.Tags { @@ -148,7 +144,9 @@ func (p Plugin) Exec() error { trace(cmd) err := cmd.Run() - if err != nil { + if err != nil && cmd.Args[1] == "pull" { + fmt.Printf("Could not pull cache-from image %s. Ignoring...\n", cmd.Args[2]) + } else if err != nil { return err } }