Skip to content

Commit

Permalink
Merge pull request #360 from Juniper/feat/359-proxy-support
Browse files Browse the repository at this point in the history
Add support for HTTP/HTTPS/SOCKS5 proxies
  • Loading branch information
chrismarget-j authored Sep 22, 2023
2 parents 398e402 + 23e9ab2 commit 5da53eb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apstra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 10 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5da53eb

Please sign in to comment.