Skip to content

Commit f80a7b9

Browse files
committed
use HTTP_PROXY in transport object for registry endpoint if defined in environment
1 parent da58411 commit f80a7b9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/registry/endpoints.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"math"
77
"net/http"
8+
"net/url"
9+
"os"
810
"strings"
911
"sync"
1012
"time"
@@ -208,11 +210,20 @@ func (ep *RegistryEndpoint) DeepCopy() *RegistryEndpoint {
208210

209211
// GetTransport returns a transport object for this endpoint
210212
func (ep *RegistryEndpoint) GetTransport() *http.Transport {
213+
transport := http.Transport{}
211214
tlsC := &tls.Config{}
215+
212216
if ep.Insecure {
213217
tlsC.InsecureSkipVerify = true
214218
}
215-
return &http.Transport{TLSClientConfig: tlsC}
219+
transport.TLSClientConfig = tlsC
220+
221+
if proxy, ok := os.LookupEnv("HTTP_PROXY"); ok {
222+
proxyUrl, _ := url.Parse(proxy)
223+
transport.Proxy = http.ProxyURL(proxyUrl)
224+
}
225+
226+
return &transport
216227
}
217228

218229
func init() {

0 commit comments

Comments
 (0)