Skip to content

Commit

Permalink
allow remote.DefaultTransport to be overridden by an http.RoundTripper (
Browse files Browse the repository at this point in the history
#1449)

* allow remote.DefaultTransport to be overridden by an http.RoundTripper

* lint finding
  • Loading branch information
imjasonh committed Sep 20, 2022
1 parent f981b4c commit e3b94c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions cmd/crane/cmd/root.go
Expand Up @@ -70,12 +70,16 @@ func New(use, short string, options []crane.Option) *cobra.Command {

options = append(options, crane.WithPlatform(platform.platform))

transport := remote.DefaultTransport.Clone()
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: insecure, //nolint: gosec
rt := remote.DefaultTransport
if t, ok := remote.DefaultTransport.(interface {
Clone() *http.Transport
}); ok {
t := t.Clone()
t.TLSClientConfig = &tls.Config{
InsecureSkipVerify: insecure, //nolint: gosec
}
}

var rt http.RoundTripper = transport
// Add any http headers if they are set in the config file.
cf, err := config.Load(os.Getenv("DOCKER_CONFIG"))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/remote/options.go
Expand Up @@ -84,7 +84,7 @@ const (

// DefaultTransport is based on http.DefaultTransport with modifications
// documented inline below.
var DefaultTransport = &http.Transport{
var DefaultTransport http.RoundTripper = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
// By default we wrap the transport in retries, so reduce the
Expand Down

0 comments on commit e3b94c7

Please sign in to comment.