prevent index out of bounds

This commit is contained in:
shimun 2018-11-05 19:43:29 +01:00
parent b31b4bf099
commit 47f3b4bb08

View File

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