From 23e9ab29595ba1feb5c0bd0606b29d91c372bcc4 Mon Sep 17 00:00:00 2001 From: Chris Marget Date: Wed, 20 Sep 2023 17:40:28 -0400 Subject: [PATCH] add proxy support --- apstra/provider.go | 7 ++++++- docs/index.md | 10 ++++++++++ templates/index.md.tmpl | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apstra/provider.go b/apstra/provider.go index caf03131..be015bd5 100644 --- a/apstra/provider.go +++ b/apstra/provider.go @@ -266,9 +266,14 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, // Set the experimental flag according to the configuration clientCfg.Experimental = config.Experimental.ValueBool() - // Set the TLS InsecureSkipVerify according to the configuration + // Set http client transport configuration if transport, ok := clientCfg.HttpClient.Transport.(*http.Transport); ok { + // Set the TLS InsecureSkipVerify according to the configuration transport.TLSClientConfig.InsecureSkipVerify = config.TlsNoVerify.ValueBool() + + // Set HTTP/HTTPS proxies according to the environment + transport.Proxy = http.ProxyFromEnvironment + clientCfg.HttpClient.Transport = transport } diff --git a/docs/index.md b/docs/index.md index 8c1d8ce0..9418c3b8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,6 +35,16 @@ embedding them in the URL string using Please consider whether writing credentials to a configuration file is acceptable in your environment. +### Proxy Support + +HTTP, HTTPS, and SOCKS5 proxies are supported through the `HTTP_PROXY` and +`HTTPS_PROXY` environment variables or the lowercase versions of those +variables. The value of each may be either a complete URL or a "host[:port]", +in which case the "http" scheme is assumed. + +Hosts which should be omitted from the proxy configuration may be listed in +the `NO_PROXY` (or `no_proxy`) environment variable ([details](https://github.com/golang/go/blob/682a1d2176b02337460aeede0ff9e49429525195/src/vendor/golang.org/x/net/http/httpproxy/proxy.go#L38C1-L50C13)). + ### Additional Environment Variables Provider attributes which have been omitted from the configuration diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 5070136f..9be221b0 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -28,6 +28,16 @@ embedding them in the URL string using Please consider whether writing credentials to a configuration file is acceptable in your environment. +### Proxy Support + +HTTP, HTTPS, and SOCKS5 proxies are supported through the `HTTP_PROXY` and +`HTTPS_PROXY` environment variables or the lowercase versions of those +variables. The value of each may be either a complete URL or a "host[:port]", +in which case the "http" scheme is assumed. + +Hosts which should be omitted from the proxy configuration may be listed in +the `NO_PROXY` (or `no_proxy`) environment variable ([details](https://github.com/golang/go/blob/682a1d2176b02337460aeede0ff9e49429525195/src/vendor/golang.org/x/net/http/httpproxy/proxy.go#L38C1-L50C13)). + ### Additional Environment Variables Provider attributes which have been omitted from the configuration