Skip to content

Commit e3b94c7

Browse files
authored
allow remote.DefaultTransport to be overridden by an http.RoundTripper (#1449)
* allow remote.DefaultTransport to be overridden by an http.RoundTripper * lint finding
1 parent f981b4c commit e3b94c7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

cmd/crane/cmd/root.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ func New(use, short string, options []crane.Option) *cobra.Command {
7070

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

73-
transport := remote.DefaultTransport.Clone()
74-
transport.TLSClientConfig = &tls.Config{
75-
InsecureSkipVerify: insecure, //nolint: gosec
73+
rt := remote.DefaultTransport
74+
if t, ok := remote.DefaultTransport.(interface {
75+
Clone() *http.Transport
76+
}); ok {
77+
t := t.Clone()
78+
t.TLSClientConfig = &tls.Config{
79+
InsecureSkipVerify: insecure, //nolint: gosec
80+
}
7681
}
7782

78-
var rt http.RoundTripper = transport
7983
// Add any http headers if they are set in the config file.
8084
cf, err := config.Load(os.Getenv("DOCKER_CONFIG"))
8185
if err != nil {

pkg/v1/remote/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const (
8484

8585
// DefaultTransport is based on http.DefaultTransport with modifications
8686
// documented inline below.
87-
var DefaultTransport = &http.Transport{
87+
var DefaultTransport http.RoundTripper = &http.Transport{
8888
Proxy: http.ProxyFromEnvironment,
8989
DialContext: (&net.Dialer{
9090
// By default we wrap the transport in retries, so reduce the

0 commit comments

Comments
 (0)