From 338e24521c4a9bac82aa9e3a5cd4397f36fa25c0 Mon Sep 17 00:00:00 2001 From: Tobias Bauriedel Date: Thu, 21 Dec 2023 13:22:20 +0100 Subject: [PATCH] add proxy environment --- modules/icinga2/api.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/icinga2/api.go b/modules/icinga2/api.go index 62c3664..c831f98 100644 --- a/modules/icinga2/api.go +++ b/modules/icinga2/api.go @@ -76,9 +76,10 @@ func endpointIsReachable(endpoint string) error { func collectStatus(endpoint string, c *collection.Collection) error { c.Log.Debugf("request data from endpoint '%s/v1/status'", endpoint) - // allow insecure connections because of Icinga 2 certificates + // allow insecure connections because of Icinga 2 certificates and add proxy if one is defined in the environments tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec + Proxy: http.ProxyFromEnvironment, } client := &http.Client{Transport: tr} @@ -87,7 +88,7 @@ func collectStatus(endpoint string, c *collection.Collection) error { defer cancel() // build request - req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://%s/v1/status", endpoint), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://%s/v1/status", endpoint), nil) if err != nil { return fmt.Errorf("cant build new request for '%s': %w", endpoint, err) }