Package: golang-github-prometheus-common / 0.15.0-2

0002-Revert-API-break-in-NewClientFromConfig.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From: Shengjing Zhu <zhsj@debian.org>
Date: Sun, 25 Oct 2020 17:07:25 +0800
Subject: Revert API break in NewClientFromConfig

This patch can be dropped once prometheus-alertmanager is adapted to
the new API.

Forwarded: not-needed
---
 config/http_config.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/config/http_config.go b/config/http_config.go
index 4dd8875..38f50cb 100644
--- a/config/http_config.go
+++ b/config/http_config.go
@@ -141,7 +141,16 @@ func newClient(rt http.RoundTripper) *http.Client {
 
 // NewClientFromConfig returns a new HTTP client configured for the
 // given config.HTTPClientConfig. The name is used as go-conntrack metric label.
-func NewClientFromConfig(cfg HTTPClientConfig, name string, disableKeepAlives, enableHTTP2 bool) (*http.Client, error) {
+func NewClientFromConfig(cfg HTTPClientConfig, name string, bools ...bool) (*http.Client, error) {
+	disableKeepAlives := false
+	enableHTTP2 := true
+	if len(bools) == 1 {
+		disableKeepAlives = bools[0]
+	}
+	if len(bools) == 2 {
+		disableKeepAlives = bools[0]
+		enableHTTP2 = bools[1]
+	}
 	rt, err := NewRoundTripperFromConfig(cfg, name, disableKeepAlives, enableHTTP2)
 	if err != nil {
 		return nil, err