Skip to content

Commit

Permalink
[v16] [buddy] fix: use proxy from env for compatible integrations (#4…
Browse files Browse the repository at this point in the history
…7738)

* fix: use proxy from env for pagerduty integration

* feat: add proxy conf for integrations that support it

Signed-off-by: Tiago Silva <[email protected]>

---------

Signed-off-by: Tiago Silva <[email protected]>
Co-authored-by: Hugo Blanc <[email protected]>
  • Loading branch information
tigrato and hugodocto authored Oct 29, 2024
1 parent 366b614 commit 6e9ee9e
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions integrations/access/datadog/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func NewDatadogClient(conf DatadogConfig, webProxyAddr string, statusSink common
Transport: &http.Transport{
MaxConnsPerHost: datadogMaxConns,
MaxIdleConnsPerHost: datadogMaxConns,
Proxy: http.ProxyFromEnvironment,
}}).
SetBaseURL(apiEndpoint).
SetHeader("Accept", "application/json").
Expand Down
1 change: 1 addition & 0 deletions integrations/access/discord/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot,
Transport: &http.Transport{
MaxConnsPerHost: discordMaxConns,
MaxIdleConnsPerHost: discordMaxConns,
Proxy: http.ProxyFromEnvironment,
},
}).
SetBaseURL(c.Discord.APIURL).
Expand Down
1 change: 1 addition & 0 deletions integrations/access/jira/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func NewJiraClient(conf JiraConfig, clusterName, teleportProxyAddr string, statu
Transport: &http.Transport{
MaxConnsPerHost: jiraMaxConns,
MaxIdleConnsPerHost: jiraMaxConns,
Proxy: http.ProxyFromEnvironment,
}}).
SetBaseURL(conf.URL).
SetBasicAuth(conf.Username, conf.APIToken).
Expand Down
1 change: 1 addition & 0 deletions integrations/access/mattermost/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func NewBot(conf Config, clusterName, webProxyAddr string) (Bot, error) {
Transport: &http.Transport{
MaxConnsPerHost: mmMaxConns,
MaxIdleConnsPerHost: mmMaxConns,
Proxy: http.ProxyFromEnvironment,
},
}).
SetBaseURL(conf.Mattermost.URL).
Expand Down
3 changes: 3 additions & 0 deletions integrations/access/opsgenie/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func (cfg *ClientConfig) CheckAndSetDefaults() error {
// NewClient creates a new Opsgenie client for managing alerts.
func NewClient(conf ClientConfig) (*Client, error) {
client := resty.NewWithClient(defaults.Config().HTTPClient)
client.SetTransport(&http.Transport{
Proxy: http.ProxyFromEnvironment,
})
client.SetHeader("Authorization", "GenieKey "+conf.APIKey)
client.SetBaseURL(conf.APIEndpoint)
return &Client{
Expand Down
1 change: 1 addition & 0 deletions integrations/access/pagerduty/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func NewPagerdutyClient(conf PagerdutyConfig, clusterName, webProxyAddr string,
Transport: &http.Transport{
MaxConnsPerHost: pdMaxConns,
MaxIdleConnsPerHost: pdMaxConns,
Proxy: http.ProxyFromEnvironment,
}}).
SetBaseURL(conf.APIEndpoint).
SetHeader("Accept", "application/vnd.pagerduty+json;version=2").
Expand Down
3 changes: 3 additions & 0 deletions integrations/access/servicenow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func NewClient(conf ClientConfig) (*Client, error) {
return nil, trace.Wrap(err)
}
client := resty.NewWithClient(defaults.Config().HTTPClient)
client.SetTransport(&http.Transport{
Proxy: http.ProxyFromEnvironment,
})
apiURL, err := url.Parse(conf.APIEndpoint)
if err != nil {
return nil, trace.Wrap(err)
Expand Down
1 change: 0 additions & 1 deletion integrations/access/slack/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot,
return nil
}).
OnAfterResponse(onAfterResponseSlack(c.StatusSink))

return Bot{
client: client,
clock: c.Clock,
Expand Down
5 changes: 4 additions & 1 deletion integrations/access/slack/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ func makeSlackClient(apiURL string) *resty.Client {
}).
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBaseURL(apiURL)
SetBaseURL(apiURL).
SetTransport(&http.Transport{
Proxy: http.ProxyFromEnvironment,
})
}

0 comments on commit 6e9ee9e

Please sign in to comment.