Skip to content

Commit

Permalink
prevent index out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
shimunn committed Nov 5, 2018
1 parent b31b4bf commit 47f3b4b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -170,6 +170,11 @@ func commandLogin(login Login) *exec.Cmd {
)
}

// helper to check if args match "docker pull <image>"
func isCommandPull(args []string) bool {
return len(args) > 2 && args[1] == "pull"
}

func commandPull(repo string) *exec.Cmd {
return exec.Command(dockerExe, "pull", repo)
}
Expand Down

0 comments on commit 47f3b4b

Please sign in to comment.