1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon/info: remove use of docker/go-connections

The `docker/go-connections` package was only used for a quite generic utility.

This patch removes the use of the package by replacing the `GetProxyEnv` utility with
a local function that's based on the one in golang.org/x/net/http/httpproxy:
c21de06aaf/http/httpproxy/proxy.go (L100-L107)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-09-25 10:56:41 +02:00
parent ef89d70aed
commit 0f0e3163b5
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -20,7 +20,6 @@ import (
"github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
"github.com/docker/docker/registry" "github.com/docker/docker/registry"
"github.com/docker/go-connections/sockets"
metrics "github.com/docker/go-metrics" metrics "github.com/docker/go-metrics"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -66,9 +65,9 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
ServerVersion: dockerversion.Version, ServerVersion: dockerversion.Version,
ClusterStore: daemon.configStore.ClusterStore, ClusterStore: daemon.configStore.ClusterStore,
ClusterAdvertise: daemon.configStore.ClusterAdvertise, ClusterAdvertise: daemon.configStore.ClusterAdvertise,
HTTPProxy: maskCredentials(sockets.GetProxyEnv("http_proxy")), HTTPProxy: maskCredentials(getEnvAny("HTTP_PROXY", "http_proxy")),
HTTPSProxy: maskCredentials(sockets.GetProxyEnv("https_proxy")), HTTPSProxy: maskCredentials(getEnvAny("HTTPS_PROXY", "https_proxy")),
NoProxy: sockets.GetProxyEnv("no_proxy"), NoProxy: getEnvAny("NO_PROXY", "no_proxy"),
LiveRestoreEnabled: daemon.configStore.LiveRestoreEnabled, LiveRestoreEnabled: daemon.configStore.LiveRestoreEnabled,
Isolation: daemon.defaultIsolation, Isolation: daemon.defaultIsolation,
} }
@ -287,3 +286,12 @@ func maskCredentials(rawURL string) string {
maskedURL := parsedURL.String() maskedURL := parsedURL.String()
return maskedURL return maskedURL
} }
func getEnvAny(names ...string) string {
for _, n := range names {
if val := os.Getenv(n); val != "" {
return val
}
}
return ""
}