From bbb3d74744441e929a7daa4e530f6300714e6a4f Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Tue, 8 May 2018 15:06:11 -0400 Subject: [PATCH] client/driver: use correct repo address when using docker-credential helper --- CHANGELOG.md | 3 +++ client/driver/docker.go | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db99c39eb303..5823aeea6cf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ IMPROVEMENTS: * env: Default interpolation of optional meta fields of parameterized jobs to an empty string rather than the field key. [[GH-3720](https://github.com/hashicorp/nomad/issues/3720)] +BUG FIXES: + * driver/docker: Fix docker credential helper support [[GH-3818](https://github.com/hashicorp/nomad/issues/3818)] [[GH-4221](https://github.com/hashicorp/nomad/issues/4221)] + ## 0.8.3 (April 27, 2018) BUG FIXES: diff --git a/client/driver/docker.go b/client/driver/docker.go index cc31e547eae3..d6a326017289 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -2130,13 +2130,15 @@ func authFromHelper(helperName string) authBackend { helper := dockerAuthHelperPrefix + helperName cmd := exec.Command(helper, "get") - // Ensure that the HTTPs prefix exists - if !strings.HasPrefix(repo, "https://") { - repo = fmt.Sprintf("https://%s", repo) + repoInfo, err := parseRepositoryInfo(repo) + if err != nil { + return nil, err } - cmd.Stdin = strings.NewReader(repo) + // Ensure that the HTTPs prefix exists + repoAddr := fmt.Sprintf("https://%s", repoInfo.Hostname()) + cmd.Stdin = strings.NewReader(repoAddr) output, err := cmd.Output() if err != nil { switch err.(type) {