From 112f5abdaeba476380404eef7772d7b90356a94b Mon Sep 17 00:00:00 2001 From: Rickard von Essen Date: Wed, 11 Jan 2017 20:21:13 +0100 Subject: [PATCH] docker: Fix crash when performing log in to ECR with an invalid URL. Closes #4383 --- builder/docker/ecr_login.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builder/docker/ecr_login.go b/builder/docker/ecr_login.go index 1ee984763..6d2df0877 100644 --- a/builder/docker/ecr_login.go +++ b/builder/docker/ecr_login.go @@ -52,6 +52,9 @@ func (c *AwsAccessConfig) EcrGetLogin(ecrUrl string) (string, string, error) { exp := regexp.MustCompile("(?:http://|https://|)([0-9]*)\\.dkr\\.ecr\\.(.*)\\.amazonaws\\.com.*") splitUrl := exp.FindStringSubmatch(ecrUrl) + if len(splitUrl) != 3 { + return "", "", fmt.Errorf("Failed to parse the ECR URL: %s it should be on the form .dkr.ecr..amazonaws.com", ecrUrl) + } accountId := splitUrl[1] region := splitUrl[2]