Skip to content

Commit 6e9ee9e

Browse files
tigratohugodocto
andauthored
[v16] [buddy] fix: use proxy from env for compatible integrations (#47738)
* fix: use proxy from env for pagerduty integration * feat: add proxy conf for integrations that support it Signed-off-by: Tiago Silva <tiago.silva@goteleport.com> --------- Signed-off-by: Tiago Silva <tiago.silva@goteleport.com> Co-authored-by: Hugo Blanc <hugo.blanc@doctolib.com>
1 parent 366b614 commit 6e9ee9e

File tree

9 files changed

+15
-2
lines changed

9 files changed

+15
-2
lines changed

integrations/access/datadog/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func NewDatadogClient(conf DatadogConfig, webProxyAddr string, statusSink common
7575
Transport: &http.Transport{
7676
MaxConnsPerHost: datadogMaxConns,
7777
MaxIdleConnsPerHost: datadogMaxConns,
78+
Proxy: http.ProxyFromEnvironment,
7879
}}).
7980
SetBaseURL(apiEndpoint).
8081
SetHeader("Accept", "application/json").

integrations/access/discord/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot,
109109
Transport: &http.Transport{
110110
MaxConnsPerHost: discordMaxConns,
111111
MaxIdleConnsPerHost: discordMaxConns,
112+
Proxy: http.ProxyFromEnvironment,
112113
},
113114
}).
114115
SetBaseURL(c.Discord.APIURL).

integrations/access/jira/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func NewJiraClient(conf JiraConfig, clusterName, teleportProxyAddr string, statu
9999
Transport: &http.Transport{
100100
MaxConnsPerHost: jiraMaxConns,
101101
MaxIdleConnsPerHost: jiraMaxConns,
102+
Proxy: http.ProxyFromEnvironment,
102103
}}).
103104
SetBaseURL(conf.URL).
104105
SetBasicAuth(conf.Username, conf.APIToken).

integrations/access/mattermost/bot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func NewBot(conf Config, clusterName, webProxyAddr string) (Bot, error) {
116116
Transport: &http.Transport{
117117
MaxConnsPerHost: mmMaxConns,
118118
MaxIdleConnsPerHost: mmMaxConns,
119+
Proxy: http.ProxyFromEnvironment,
119120
},
120121
}).
121122
SetBaseURL(conf.Mattermost.URL).

integrations/access/opsgenie/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ func (cfg *ClientConfig) CheckAndSetDefaults() error {
116116
// NewClient creates a new Opsgenie client for managing alerts.
117117
func NewClient(conf ClientConfig) (*Client, error) {
118118
client := resty.NewWithClient(defaults.Config().HTTPClient)
119+
client.SetTransport(&http.Transport{
120+
Proxy: http.ProxyFromEnvironment,
121+
})
119122
client.SetHeader("Authorization", "GenieKey "+conf.APIKey)
120123
client.SetBaseURL(conf.APIEndpoint)
121124
return &Client{

integrations/access/pagerduty/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func NewPagerdutyClient(conf PagerdutyConfig, clusterName, webProxyAddr string,
8989
Transport: &http.Transport{
9090
MaxConnsPerHost: pdMaxConns,
9191
MaxIdleConnsPerHost: pdMaxConns,
92+
Proxy: http.ProxyFromEnvironment,
9293
}}).
9394
SetBaseURL(conf.APIEndpoint).
9495
SetHeader("Accept", "application/vnd.pagerduty+json;version=2").

integrations/access/servicenow/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ func NewClient(conf ClientConfig) (*Client, error) {
102102
return nil, trace.Wrap(err)
103103
}
104104
client := resty.NewWithClient(defaults.Config().HTTPClient)
105+
client.SetTransport(&http.Transport{
106+
Proxy: http.ProxyFromEnvironment,
107+
})
105108
apiURL, err := url.Parse(conf.APIEndpoint)
106109
if err != nil {
107110
return nil, trace.Wrap(err)

integrations/access/slack/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot,
139139
return nil
140140
}).
141141
OnAfterResponse(onAfterResponseSlack(c.StatusSink))
142-
143142
return Bot{
144143
client: client,
145144
clock: c.Clock,

integrations/access/slack/http.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@ func makeSlackClient(apiURL string) *resty.Client {
3737
}).
3838
SetHeader("Content-Type", "application/json").
3939
SetHeader("Accept", "application/json").
40-
SetBaseURL(apiURL)
40+
SetBaseURL(apiURL).
41+
SetTransport(&http.Transport{
42+
Proxy: http.ProxyFromEnvironment,
43+
})
4144
}

0 commit comments

Comments
 (0)