From e39da6e1c92035e674418dff94a2e4c97b436b3c Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 14 Sep 2017 10:19:31 -0400 Subject: [PATCH] update go-getter --- .../github.com/hashicorp/go-getter/README.md | 3 +- .../hashicorp/go-getter/detect_file.go | 2 +- vendor/github.com/hashicorp/go-getter/get.go | 9 +++++- .../github.com/hashicorp/go-getter/get_git.go | 29 +++++++++++++++---- .../hashicorp/go-getter/get_http.go | 16 ++++++++-- vendor/vendor.json | 14 +++++---- 6 files changed, 56 insertions(+), 17 deletions(-) diff --git a/vendor/github.com/hashicorp/go-getter/README.md b/vendor/github.com/hashicorp/go-getter/README.md index 80623105f..a9eafd61f 100644 --- a/vendor/github.com/hashicorp/go-getter/README.md +++ b/vendor/github.com/hashicorp/go-getter/README.md @@ -21,8 +21,7 @@ URLs. For example: "github.com/hashicorp/go-getter" would turn into a Git URL. Or "./foo" would turn into a file URL. These are extensible. This library is used by [Terraform](https://terraform.io) for -downloading modules, [Otto](https://ottoproject.io) for dependencies and -Appfile imports, and [Nomad](https://nomadproject.io) for downloading +downloading modules and [Nomad](https://nomadproject.io) for downloading binaries. ## Installation and Usage diff --git a/vendor/github.com/hashicorp/go-getter/detect_file.go b/vendor/github.com/hashicorp/go-getter/detect_file.go index 756ea43f8..4ef41ea73 100644 --- a/vendor/github.com/hashicorp/go-getter/detect_file.go +++ b/vendor/github.com/hashicorp/go-getter/detect_file.go @@ -32,7 +32,7 @@ func (d *FileDetector) Detect(src, pwd string) (string, bool, error) { return "", true, err } if fi.Mode()&os.ModeSymlink != 0 { - pwd, err = os.Readlink(pwd) + pwd, err = filepath.EvalSymlinks(pwd) if err != nil { return "", true, err } diff --git a/vendor/github.com/hashicorp/go-getter/get.go b/vendor/github.com/hashicorp/go-getter/get.go index c3236f553..e6053d934 100644 --- a/vendor/github.com/hashicorp/go-getter/get.go +++ b/vendor/github.com/hashicorp/go-getter/get.go @@ -18,6 +18,8 @@ import ( "os/exec" "regexp" "syscall" + + cleanhttp "github.com/hashicorp/go-cleanhttp" ) // Getter defines the interface that schemes must implement to download @@ -49,8 +51,13 @@ var Getters map[string]Getter // syntax is schema::url, example: git::https://foo.com var forcedRegexp = regexp.MustCompile(`^([A-Za-z0-9]+)::(.+)$`) +// httpClient is the default client to be used by HttpGetters. +var httpClient = cleanhttp.DefaultClient() + func init() { - httpGetter := &HttpGetter{Netrc: true} + httpGetter := &HttpGetter{ + Netrc: true, + } Getters = map[string]Getter{ "file": new(FileGetter), diff --git a/vendor/github.com/hashicorp/go-getter/get_git.go b/vendor/github.com/hashicorp/go-getter/get_git.go index 072813983..6f5d9142b 100644 --- a/vendor/github.com/hashicorp/go-getter/get_git.go +++ b/vendor/github.com/hashicorp/go-getter/get_git.go @@ -180,17 +180,34 @@ func (g *GitGetter) fetchSubmodules(dst, sshKeyFile string) error { // setupGitEnv sets up the environment for the given command. This is used to // pass configuration data to git and ssh and enables advanced cloning methods. func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) { - var sshOpts []string + const gitSSHCommand = "GIT_SSH_COMMAND=" + var sshCmd []string + + // If we have an existing GIT_SSH_COMMAND, we need to append our options. + // We will also remove our old entry to make sure the behavior is the same + // with versions of Go < 1.9. + env := os.Environ() + for i, v := range env { + if strings.HasPrefix(v, gitSSHCommand) { + sshCmd = []string{v} + + env[i], env[len(env)-1] = env[len(env)-1], env[i] + env = env[:len(env)-1] + break + } + } + + if len(sshCmd) == 0 { + sshCmd = []string{gitSSHCommand + "ssh"} + } if sshKeyFile != "" { // We have an SSH key temp file configured, tell ssh about this. - sshOpts = append(sshOpts, "-i", sshKeyFile) + sshCmd = append(sshCmd, "-i", sshKeyFile) } - cmd.Env = append(os.Environ(), - // Set the ssh command to use for clones. - "GIT_SSH_COMMAND=ssh "+strings.Join(sshOpts, " "), - ) + env = append(env, strings.Join(sshCmd, " ")) + cmd.Env = env } // checkGitVersion is used to check the version of git installed on the system diff --git a/vendor/github.com/hashicorp/go-getter/get_http.go b/vendor/github.com/hashicorp/go-getter/get_http.go index dbcb3ab1f..9acc72cd7 100644 --- a/vendor/github.com/hashicorp/go-getter/get_http.go +++ b/vendor/github.com/hashicorp/go-getter/get_http.go @@ -36,6 +36,10 @@ type HttpGetter struct { // Netrc, if true, will lookup and use auth information found // in the user's netrc file if available. Netrc bool + + // Client is the http.Client to use for Get requests. + // This defaults to a cleanhttp.DefaultClient if left unset. + Client *http.Client } func (g *HttpGetter) ClientMode(u *url.URL) (ClientMode, error) { @@ -57,13 +61,17 @@ func (g *HttpGetter) Get(dst string, u *url.URL) error { } } + if g.Client == nil { + g.Client = httpClient + } + // Add terraform-get to the parameter. q := u.Query() q.Add("terraform-get", "1") u.RawQuery = q.Encode() // Get the URL - resp, err := http.Get(u.String()) + resp, err := g.Client.Get(u.String()) if err != nil { return err } @@ -105,7 +113,11 @@ func (g *HttpGetter) GetFile(dst string, u *url.URL) error { } } - resp, err := http.Get(u.String()) + if g.Client == nil { + g.Client = httpClient + } + + resp, err := g.Client.Get(u.String()) if err != nil { return err } diff --git a/vendor/vendor.json b/vendor/vendor.json index b29b6b090..19af83af9 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1366,16 +1366,20 @@ "revisionTime": "2017-02-11T01:34:15Z" }, { - "checksumSHA1": "cw5fzHNCbc3zVjNRnP1pm5tt5rk=", + "checksumSHA1": "7SY5eTKPGF0BjyByXfKhZAAqnKc=", "path": "github.com/hashicorp/go-getter", - "revision": "ee320eed76420de7fa4395de568552c63fe9115e", - "revisionTime": "2017-09-05T20:45:58Z" + "revision": "56c651a79a6eec93e6ef074fe9e57fefb26b8b85", + "revisionTime": "2017-09-14T15:44:44Z", + "version": "master", + "versionExact": "master" }, { "checksumSHA1": "9J+kDr29yDrwsdu2ULzewmqGjpA=", "path": "github.com/hashicorp/go-getter/helper/url", - "revision": "6aae8e4e2dee8131187c6a54b52664796e5a02b0", - "revisionTime": "2017-07-13T01:23:01Z" + "revision": "56c651a79a6eec93e6ef074fe9e57fefb26b8b85", + "revisionTime": "2017-09-14T15:44:44Z", + "version": "master", + "versionExact": "master" }, { "checksumSHA1": "miVF4/7JP0lRwZvFJGKwZWk7aAQ=",