diff --git a/docker.go b/docker.go index 8cea3fc..c3c7332 100644 --- a/docker.go +++ b/docker.go @@ -144,7 +144,7 @@ func (p Plugin) Exec() error { trace(cmd) err := cmd.Run() - if err != nil && cmd.Args[1] == "pull" { + if err != nil && isCommandPull(cmd.Args) { fmt.Printf("Could not pull cache-from image %s. Ignoring...\n", cmd.Args[2]) } else if err != nil { return err @@ -170,6 +170,11 @@ func commandLogin(login Login) *exec.Cmd { ) } +// helper to check if args match "docker pull " +func isCommandPull(args []string) bool { + return len(args) > 2 && args[1] == "pull" +} + func commandPull(repo string) *exec.Cmd { return exec.Command(dockerExe, "pull", repo) }