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