vendor: update go-getter

This commit is contained in:
Mitchell Hashimoto 2016-08-30 15:54:31 -07:00
parent b709d27cf7
commit a1c4e1a97b
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 83 additions and 5 deletions

View File

@ -46,7 +46,7 @@ var Getters map[string]Getter
var forcedRegexp = regexp.MustCompile(`^([A-Za-z0-9]+)::(.+)$`)
func init() {
httpGetter := new(HttpGetter)
httpGetter := &HttpGetter{Netrc: true}
Getters = map[string]Getter{
"file": new(FileGetter),

View File

@ -32,13 +32,24 @@ import (
// The source URL, whether from the header or meta tag, must be a fully
// formed URL. The shorthand syntax of "github.com/foo/bar" or relative
// paths are not allowed.
type HttpGetter struct{}
type HttpGetter struct {
// Netrc, if true, will lookup and use auth information found
// in the user's netrc file if available.
Netrc bool
}
func (g *HttpGetter) Get(dst string, u *url.URL) error {
// Copy the URL so we can modify it
var newU url.URL = *u
u = &newU
if g.Netrc {
// Add auth from netrc if we can
if err := addAuthFromNetrc(u); err != nil {
return err
}
}
// Add terraform-get to the parameter.
q := u.Query()
q.Add("terraform-get", "1")

67
vendor/github.com/hashicorp/go-getter/netrc.go generated vendored Normal file
View File

@ -0,0 +1,67 @@
package getter
import (
"fmt"
"net/url"
"os"
"runtime"
"github.com/bgentry/go-netrc/netrc"
"github.com/mitchellh/go-homedir"
)
// addAuthFromNetrc adds auth information to the URL from the user's
// netrc file if it can be found. This will only add the auth info
// if the URL doesn't already have auth info specified and the
// the username is blank.
func addAuthFromNetrc(u *url.URL) error {
// If the URL already has auth information, do nothing
if u.User != nil && u.User.Username() != "" {
return nil
}
// Get the netrc file path
path := os.Getenv("NETRC")
if path == "" {
filename := ".netrc"
if runtime.GOOS == "windows" {
filename = "_netrc"
}
var err error
path, err = homedir.Expand("~/" + filename)
if err != nil {
return err
}
}
// If the file is not a file, then do nothing
if fi, err := os.Stat(path); err != nil {
// File doesn't exist, do nothing
if os.IsNotExist(err) {
return nil
}
// Some other error!
return err
} else if fi.IsDir() {
// File is directory, ignore
return nil
}
// Load up the netrc file
net, err := netrc.ParseFile(path)
if err != nil {
return fmt.Errorf("Error parsing netrc file at %q: %s", path, err)
}
machine := net.FindMachine(u.Host)
if machine == nil {
// Machine not found, no problem
return nil
}
// Set the user info
u.User = url.UserPassword(machine.Login, machine.Password)
return nil
}

6
vendor/vendor.json vendored
View File

@ -1126,10 +1126,10 @@
"revision": "875fb671b3ddc66f8e2f0acc33829c8cb989a38d"
},
{
"checksumSHA1": "MN8EmPozxjt3pyOCYfsO5Pon8V0=",
"checksumSHA1": "Qw7bz5IlDicreRjfyiB8QBJi0Fc=",
"path": "github.com/hashicorp/go-getter",
"revision": "a186869fff81d32bcb4e98c88c7c7d82880271ba",
"revisionTime": "2016-08-24T23:43:04Z"
"revision": "0eb633db32e432fabba9eca8fa21192fab2b96be",
"revisionTime": "2016-08-30T22:50:22Z"
},
{
"path": "github.com/hashicorp/go-getter/helper/url",