@@ -19,13 +19,10 @@ package util
19
19
import (
20
20
"crypto/tls"
21
21
"crypto/x509"
22
+ . "github.com/google/go-containerregistry/pkg/name"
22
23
"github.com/sirupsen/logrus"
23
24
"io/ioutil"
24
- "net"
25
25
"net/http"
26
- "time"
27
-
28
- . "github.com/google/go-containerregistry/pkg/name"
29
26
)
30
27
31
28
var tlsConfiguration = struct {
@@ -48,7 +45,8 @@ func ConfigureTLS(skipTsVerifyRegistries []string, registriesToCertificates map[
48
45
}
49
46
50
47
func BuildTransport (registry Registry ) http.RoundTripper {
51
- var tr http.RoundTripper = newTransport ()
48
+ var tr http.RoundTripper = http .DefaultTransport .(* http.Transport ).Clone ()
49
+
52
50
if _ , present := tlsConfiguration .skipTLSVerifyRegistries [registry .RegistryStr ()]; present {
53
51
tr .(* http.Transport ).TLSClientConfig = & tls.Config {
54
52
InsecureSkipVerify : true ,
@@ -66,22 +64,6 @@ func BuildTransport(registry Registry) http.RoundTripper {
66
64
return tr
67
65
}
68
66
69
- // TODO replace it with "http.DefaultTransport.(*http.Transport).Clone()" once in golang 1.12
70
- func newTransport () http.RoundTripper {
71
- return & http.Transport {
72
- Proxy : http .ProxyFromEnvironment ,
73
- DialContext : (& net.Dialer {
74
- Timeout : 30 * time .Second ,
75
- KeepAlive : 30 * time .Second ,
76
- DualStack : true ,
77
- }).DialContext ,
78
- MaxIdleConns : 100 ,
79
- IdleConnTimeout : 90 * time .Second ,
80
- TLSHandshakeTimeout : 10 * time .Second ,
81
- ExpectContinueTimeout : 1 * time .Second ,
82
- }
83
- }
84
-
85
67
func appendCertificate (pool * x509.CertPool , path string ) error {
86
68
pem , err := ioutil .ReadFile (path )
87
69
if err != nil {
0 commit comments