Merge pull request #39951 from yedamao/fix-base-Dial-is-deprecated
Fix base.Dial is deprecated: Use DialContext instead
This commit is contained in:
commit
6c3113e599
|
@ -16,7 +16,6 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/dockerversion"
|
"github.com/docker/docker/dockerversion"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/go-connections/sockets"
|
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,7 +55,10 @@ func init() {
|
||||||
// NewV2Repository returns a repository (v2 only). It creates an HTTP transport
|
// NewV2Repository returns a repository (v2 only). It creates an HTTP transport
|
||||||
// providing timeout settings and authentication support, and also verifies the
|
// providing timeout settings and authentication support, and also verifies the
|
||||||
// remote API version.
|
// remote API version.
|
||||||
func NewV2Repository(ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint, metaHeaders http.Header, authConfig *types.AuthConfig, actions ...string) (repo distribution.Repository, foundVersion bool, err error) {
|
func NewV2Repository(
|
||||||
|
ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint,
|
||||||
|
metaHeaders http.Header, authConfig *types.AuthConfig, actions ...string,
|
||||||
|
) (repo distribution.Repository, foundVersion bool, err error) {
|
||||||
repoName := repoInfo.Name.Name()
|
repoName := repoInfo.Name.Name()
|
||||||
// If endpoint does not support CanonicalName, use the RemoteName instead
|
// If endpoint does not support CanonicalName, use the RemoteName instead
|
||||||
if endpoint.TrimHostname {
|
if endpoint.TrimHostname {
|
||||||
|
@ -72,18 +74,13 @@ func NewV2Repository(ctx context.Context, repoInfo *registry.RepositoryInfo, end
|
||||||
// TODO(dmcgowan): Call close idle connections when complete, use keep alive
|
// TODO(dmcgowan): Call close idle connections when complete, use keep alive
|
||||||
base := &http.Transport{
|
base := &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
Dial: direct.Dial,
|
DialContext: direct.DialContext,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
TLSClientConfig: endpoint.TLSConfig,
|
TLSClientConfig: endpoint.TLSConfig,
|
||||||
// TODO(dmcgowan): Call close idle connections when complete and use keep alive
|
// TODO(dmcgowan): Call close idle connections when complete and use keep alive
|
||||||
DisableKeepAlives: true,
|
DisableKeepAlives: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyDialer, err := sockets.DialerFromEnvironment(direct)
|
|
||||||
if err == nil {
|
|
||||||
base.Dial = proxyDialer.Dial
|
|
||||||
}
|
|
||||||
|
|
||||||
modifiers := registry.Headers(dockerversion.DockerUserAgent(ctx), metaHeaders)
|
modifiers := registry.Headers(dockerversion.DockerUserAgent(ctx), metaHeaders)
|
||||||
authTransport := transport.NewTransport(base, modifiers...)
|
authTransport := transport.NewTransport(base, modifiers...)
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,6 @@ issues:
|
||||||
- text: "G202: SQL string concatenation"
|
- text: "G202: SQL string concatenation"
|
||||||
linters:
|
linters:
|
||||||
- gosec
|
- gosec
|
||||||
# FIXME temporarily suppress these. See #39925
|
|
||||||
- text: "SA1019: base.Dial is deprecated"
|
|
||||||
linters:
|
|
||||||
- staticcheck
|
|
||||||
# FIXME temporarily suppress these. See #39928
|
# FIXME temporarily suppress these. See #39928
|
||||||
- text: "SA1019: grpc.WithDialer is deprecated"
|
- text: "SA1019: grpc.WithDialer is deprecated"
|
||||||
linters:
|
linters:
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/distribution/registry/client/transport"
|
"github.com/docker/distribution/registry/client/transport"
|
||||||
"github.com/docker/go-connections/sockets"
|
|
||||||
"github.com/docker/go-connections/tlsconfig"
|
"github.com/docker/go-connections/tlsconfig"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -176,16 +175,12 @@ func NewTransport(tlsConfig *tls.Config) *http.Transport {
|
||||||
|
|
||||||
base := &http.Transport{
|
base := &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
Dial: direct.Dial,
|
DialContext: direct.DialContext,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
TLSClientConfig: tlsConfig,
|
TLSClientConfig: tlsConfig,
|
||||||
// TODO(dmcgowan): Call close idle connections when complete and use keep alive
|
// TODO(dmcgowan): Call close idle connections when complete and use keep alive
|
||||||
DisableKeepAlives: true,
|
DisableKeepAlives: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyDialer, err := sockets.DialerFromEnvironment(direct)
|
|
||||||
if err == nil {
|
|
||||||
base.Dial = proxyDialer.Dial
|
|
||||||
}
|
|
||||||
return base
|
return base
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue