From e85bac737b5be3a2bb9093537025b80a1c7f4c66 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 28 Jun 2019 14:38:54 -0700 Subject: [PATCH] update go-getter client in vendors folder --- .../github.com/hashicorp/go-getter/README.md | 10 +++++++ .../hashicorp/go-getter/checksum.go | 30 +++++++++---------- .../hashicorp/go-getter/decompress_zip.go | 2 +- .../hashicorp/go-getter/detect_bitbucket.go | 2 +- .../github.com/hashicorp/go-getter/get_git.go | 29 ++++++------------ vendor/modules.txt | 2 +- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/vendor/github.com/hashicorp/go-getter/README.md b/vendor/github.com/hashicorp/go-getter/README.md index 85884fad4..ba4df6f4b 100644 --- a/vendor/github.com/hashicorp/go-getter/README.md +++ b/vendor/github.com/hashicorp/go-getter/README.md @@ -280,6 +280,16 @@ None * `depth` - The Git clone depth. The provided number specifies the last `n` revisions to clone from the repository. + +The `git` getter accepts both URL-style SSH addresses like +`git::ssh://git@example.com/foo/bar`, and "scp-style" addresses like +`git::git@example.com/foo/bar`. In the latter case, omitting the `git::` +force prefix is allowed if the username prefix is exactly `git@`. + +The "scp-style" addresses _cannot_ be used in conjunction with the `ssh://` +scheme prefix, because in that case the colon is used to mark an optional +port number to connect on, rather than to delimit the path from the host. + ### Mercurial (`hg`) * `rev` - The Mercurial revision to checkout. diff --git a/vendor/github.com/hashicorp/go-getter/checksum.go b/vendor/github.com/hashicorp/go-getter/checksum.go index bea7ed13c..eeccfea9d 100644 --- a/vendor/github.com/hashicorp/go-getter/checksum.go +++ b/vendor/github.com/hashicorp/go-getter/checksum.go @@ -19,8 +19,8 @@ import ( urlhelper "github.com/hashicorp/go-getter/helper/url" ) -// fileChecksum helps verifying the checksum for a file. -type fileChecksum struct { +// FileChecksum helps verifying the checksum for a file. +type FileChecksum struct { Type string Hash hash.Hash Value []byte @@ -50,7 +50,7 @@ func (cerr *ChecksumError) Error() string { // checksum is a simple method to compute the checksum of a source file // and compare it to the given expected value. -func (c *fileChecksum) checksum(source string) error { +func (c *FileChecksum) checksum(source string) error { f, err := os.Open(source) if err != nil { return fmt.Errorf("Failed to open file for checksum: %s", err) @@ -74,7 +74,7 @@ func (c *fileChecksum) checksum(source string) error { return nil } -// extractChecksum will return a fileChecksum based on the 'checksum' +// extractChecksum will return a FileChecksum based on the 'checksum' // parameter of u. // ex: // http://hashicorp.com/terraform?checksum= @@ -93,7 +93,7 @@ func (c *fileChecksum) checksum(source string) error { // *file2 // // see parseChecksumLine for more detail on checksum file parsing -func (c *Client) extractChecksum(u *url.URL) (*fileChecksum, error) { +func (c *Client) extractChecksum(u *url.URL) (*FileChecksum, error) { q := u.Query() v := q.Get("checksum") @@ -115,14 +115,14 @@ func (c *Client) extractChecksum(u *url.URL) (*fileChecksum, error) { switch checksumType { case "file": - return c.checksumFromFile(checksumValue, u) + return c.ChecksumFromFile(checksumValue, u) default: return newChecksumFromType(checksumType, checksumValue, filepath.Base(u.EscapedPath())) } } -func newChecksum(checksumValue, filename string) (*fileChecksum, error) { - c := &fileChecksum{ +func newChecksum(checksumValue, filename string) (*FileChecksum, error) { + c := &FileChecksum{ Filename: filename, } var err error @@ -133,7 +133,7 @@ func newChecksum(checksumValue, filename string) (*fileChecksum, error) { return c, nil } -func newChecksumFromType(checksumType, checksumValue, filename string) (*fileChecksum, error) { +func newChecksumFromType(checksumType, checksumValue, filename string) (*FileChecksum, error) { c, err := newChecksum(checksumValue, filename) if err != nil { return nil, err @@ -157,7 +157,7 @@ func newChecksumFromType(checksumType, checksumValue, filename string) (*fileChe return c, nil } -func newChecksumFromValue(checksumValue, filename string) (*fileChecksum, error) { +func newChecksumFromValue(checksumValue, filename string) (*FileChecksum, error) { c, err := newChecksum(checksumValue, filename) if err != nil { return nil, err @@ -183,14 +183,14 @@ func newChecksumFromValue(checksumValue, filename string) (*fileChecksum, error) return c, nil } -// checksumsFromFile will return all the fileChecksums found in file +// ChecksumFromFile will return all the FileChecksums found in file // -// checksumsFromFile will try to guess the hashing algorithm based on content +// ChecksumFromFile will try to guess the hashing algorithm based on content // of checksum file // -// checksumsFromFile will only return checksums for files that match file +// ChecksumFromFile will only return checksums for files that match file // behind src -func (c *Client) checksumFromFile(checksumFile string, src *url.URL) (*fileChecksum, error) { +func (c *Client) ChecksumFromFile(checksumFile string, src *url.URL) (*FileChecksum, error) { checksumFileURL, err := urlhelper.Parse(checksumFile) if err != nil { return nil, err @@ -286,7 +286,7 @@ func (c *Client) checksumFromFile(checksumFile string, src *url.URL) (*fileCheck // of a line. // for BSD type sums parseChecksumLine guesses the hashing algorithm // by checking the length of the checksum. -func parseChecksumLine(line string) (*fileChecksum, error) { +func parseChecksumLine(line string) (*FileChecksum, error) { parts := strings.Fields(line) switch len(parts) { diff --git a/vendor/github.com/hashicorp/go-getter/decompress_zip.go b/vendor/github.com/hashicorp/go-getter/decompress_zip.go index b0e70cac3..0830f7914 100644 --- a/vendor/github.com/hashicorp/go-getter/decompress_zip.go +++ b/vendor/github.com/hashicorp/go-getter/decompress_zip.go @@ -9,7 +9,7 @@ import ( ) // ZipDecompressor is an implementation of Decompressor that can -// decompress tar.gzip files. +// decompress zip files. type ZipDecompressor struct{} func (d *ZipDecompressor) Decompress(dst, src string, dir bool) error { diff --git a/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go b/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go index a183a17df..19047eb19 100644 --- a/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go +++ b/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go @@ -35,7 +35,7 @@ func (d *BitBucketDetector) detectHTTP(src string) (string, bool, error) { var info struct { SCM string `json:"scm"` } - infoUrl := "https://api.bitbucket.org/1.0/repositories" + u.Path + infoUrl := "https://api.bitbucket.org/2.0/repositories" + u.Path resp, err := http.Get(infoUrl) if err != nil { return "", true, fmt.Errorf("error looking up BitBucket URL: %s", err) diff --git a/vendor/github.com/hashicorp/go-getter/get_git.go b/vendor/github.com/hashicorp/go-getter/get_git.go index 2ff00d20f..67e8b2f49 100644 --- a/vendor/github.com/hashicorp/go-getter/get_git.go +++ b/vendor/github.com/hashicorp/go-getter/get_git.go @@ -34,6 +34,15 @@ func (g *GitGetter) Get(dst string, u *url.URL) error { return fmt.Errorf("git must be available and on the PATH") } + // The port number must be parseable as an integer. If not, the user + // was probably trying to use a scp-style address, in which case the + // ssh:// prefix must be removed to indicate that. + if portStr := u.Port(); portStr != "" { + if _, err := strconv.ParseUint(portStr, 10, 16); err != nil { + return fmt.Errorf("invalid port number %q; if using the \"scp-like\" git address scheme where a colon introduces the path instead, remove the ssh:// portion and use just the git:: prefix", portStr) + } + } + // Extract some query parameters we use var ref, sshKey string var depth int @@ -90,26 +99,6 @@ func (g *GitGetter) Get(dst string, u *url.URL) error { } } - // For SSH-style URLs, if they use the SCP syntax of host:path, then - // the URL will be mangled. We detect that here and correct the path. - // Example: host:path/bar will turn into host/path/bar - if u.Scheme == "ssh" { - if idx := strings.Index(u.Host, ":"); idx > -1 { - // Copy the URL so we don't modify the input - var newU url.URL = *u - u = &newU - - // Path includes the part after the ':'. - u.Path = u.Host[idx+1:] + u.Path - if u.Path[0] != '/' { - u.Path = "/" + u.Path - } - - // Host trims up to the : - u.Host = u.Host[:idx] - } - } - // Clone or update the repository _, err := os.Stat(dst) if err != nil && !os.IsNotExist(err) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 0662c8155..a15b0d561 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -235,7 +235,7 @@ github.com/hashicorp/errwrap github.com/hashicorp/go-checkpoint # github.com/hashicorp/go-cleanhttp v0.5.0 github.com/hashicorp/go-cleanhttp -# github.com/hashicorp/go-getter v1.2.0 +# github.com/hashicorp/go-getter v1.3.1-0.20190627223108-da0323b9545e github.com/hashicorp/go-getter github.com/hashicorp/go-getter/helper/url # github.com/hashicorp/go-immutable-radix v1.0.0