From 8e5f70fe9a0319e72fe856cd3ebcea5bae89cc6b Mon Sep 17 00:00:00 2001 From: someshkoli Date: Sun, 7 Nov 2021 16:56:29 +0530 Subject: [PATCH] adds method to set http client to realoder Signed-off-by: someshkoli --- cmd/thanos/sidecar.go | 2 +- pkg/reloader/reloader.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index d69ce79c80c..e18985deba3 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -95,7 +95,7 @@ func runSidecar( return errors.Wrap(err, "Improper http client config") } - reloader.HTTPClient = *httpClient + reloader.SetHttpClient(*httpClient) var m = &promMetadata{ promURL: conf.prometheus.url, diff --git a/pkg/reloader/reloader.go b/pkg/reloader/reloader.go index 9d8150f1cb8..f5880054b9c 100644 --- a/pkg/reloader/reloader.go +++ b/pkg/reloader/reloader.go @@ -85,7 +85,7 @@ import ( type Reloader struct { logger log.Logger reloadURL *url.URL - HTTPClient http.Client + httpClient http.Client cfgFile string cfgOutputFile string watchInterval time.Duration @@ -414,7 +414,7 @@ func (r *Reloader) triggerReload(ctx context.Context) error { } req = req.WithContext(ctx) - resp, err := r.HTTPClient.Do(req) + resp, err := r.httpClient.Do(req) if err != nil { return errors.Wrap(err, "reload request failed") } @@ -426,6 +426,11 @@ func (r *Reloader) triggerReload(ctx context.Context) error { return nil } +// Sets Http client for reloader +func (r *Reloader) SetHttpClient(client http.Client) { + r.httpClient = client +} + // ReloadURLFromBase returns the standard Prometheus reload URL from its base URL. func ReloadURLFromBase(u *url.URL) *url.URL { r := *u