Add docker pull images to main command batch array. Among other cleanup

This commit is contained in:
Ryan Sullivan 2018-10-24 00:48:10 -04:00
parent 008bbaf47b
commit b31b4bf099
No known key found for this signature in database
GPG Key ID: A81AC24687421396
2 changed files with 9 additions and 11 deletions

View File

@ -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{

View File

@ -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
}
}