1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-05 17:00:20 +00:00

Vendor update

This commit is contained in:
galal-hussein
2017-11-02 12:04:20 +02:00
parent dbc7dfaafe
commit c4677f8ee6
1210 changed files with 525826 additions and 242 deletions

View File

@@ -11,7 +11,6 @@ import (
"net"
"net/url"
"os"
"sync"
)
// A Dialer is a means to establish a connection.
@@ -28,7 +27,7 @@ type Auth struct {
// FromEnvironment returns the dialer specified by the proxy related variables in
// the environment.
func FromEnvironment() Dialer {
allProxy := allProxyEnv.Get()
allProxy := os.Getenv("all_proxy")
if len(allProxy) == 0 {
return Direct
}
@@ -42,7 +41,7 @@ func FromEnvironment() Dialer {
return Direct
}
noProxy := noProxyEnv.Get()
noProxy := os.Getenv("no_proxy")
if len(noProxy) == 0 {
return proxy
}
@@ -93,42 +92,3 @@ func FromURL(u *url.URL, forward Dialer) (Dialer, error) {
return nil, errors.New("proxy: unknown scheme: " + u.Scheme)
}
var (
allProxyEnv = &envOnce{
names: []string{"ALL_PROXY", "all_proxy"},
}
noProxyEnv = &envOnce{
names: []string{"NO_PROXY", "no_proxy"},
}
)
// envOnce looks up an environment variable (optionally by multiple
// names) once. It mitigates expensive lookups on some platforms
// (e.g. Windows).
// (Borrowed from net/http/transport.go)
type envOnce struct {
names []string
once sync.Once
val string
}
func (e *envOnce) Get() string {
e.once.Do(e.init)
return e.val
}
func (e *envOnce) init() {
for _, n := range e.names {
e.val = os.Getenv(n)
if e.val != "" {
return
}
}
}
// reset is used by tests
func (e *envOnce) reset() {
e.once = sync.Once{}
e.val = ""
}