mirror of
https://github.com/actions-runner-controller/actions-runner-controller.git
synced 2026-10-08 03:41:19 +02:00
Add support for proxy (#2286)
Co-authored-by: Nikola Jokic <jokicnikola07@gmail.com> Co-authored-by: Tingluo Huang <tingluohuang@github.com> Co-authored-by: Ferenc Hammerl <fhammerl@github.com>
This commit is contained in:
co-authored by
Nikola Jokic
Tingluo Huang
Ferenc Hammerl
parent
ced88228fc
commit
6b4250ca90
@@ -76,8 +76,12 @@ type Client struct {
|
||||
|
||||
rootCAs *x509.CertPool
|
||||
tlsInsecureSkipVerify bool
|
||||
|
||||
proxyFunc ProxyFunc
|
||||
}
|
||||
|
||||
type ProxyFunc func(req *http.Request) (*url.URL, error)
|
||||
|
||||
type ClientOption func(*Client)
|
||||
|
||||
func WithUserAgent(userAgent string) ClientOption {
|
||||
@@ -116,6 +120,12 @@ func WithoutTLSVerify() ClientOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithProxy(proxyFunc ProxyFunc) ClientOption {
|
||||
return func(c *Client) {
|
||||
c.proxyFunc = proxyFunc
|
||||
}
|
||||
}
|
||||
|
||||
func NewClient(githubConfigURL string, creds *ActionsAuth, options ...ClientOption) (*Client, error) {
|
||||
config, err := ParseGitHubConfigFromURL(githubConfigURL)
|
||||
if err != nil {
|
||||
@@ -160,6 +170,8 @@ func NewClient(githubConfigURL string, creds *ActionsAuth, options ...ClientOpti
|
||||
transport.TLSClientConfig.InsecureSkipVerify = true
|
||||
}
|
||||
|
||||
transport.Proxy = ac.proxyFunc
|
||||
|
||||
retryClient.HTTPClient.Transport = transport
|
||||
ac.Client = retryClient.StandardClient()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user