File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,6 +104,23 @@ func buildTransport(opts ClientOpts, flags *Flags) *http.Transport {
104104 return transport
105105}
106106
107+ // envProxyURL resolves the proxy URL
108+ // from standard HTTP_PROXY/HTTPS_PROXY/NO_PROXY
109+ // environment variables for the given endpoint.
110+ // Returns nil if the endpoint is not a valid URL,
111+ // no proxy is configured, or the endpoint is excluded.
112+ func envProxyURL (endpoint string ) * url.URL {
113+ u , err := url .Parse (endpoint )
114+ if err != nil || u .Scheme == "" || u .Host == "" {
115+ return nil
116+ }
117+ proxyURL , err := http .ProxyFromEnvironment (& http.Request {URL : u })
118+ if err != nil || proxyURL == nil {
119+ return nil
120+ }
121+ return proxyURL
122+ }
123+
107124// NewClient creates a new API client.
108125func NewClient (opts ClientOpts ) Client {
109126 if opts .Out == nil {
You can’t perform that action at this time.
0 commit comments