diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-08-11 17:40:19 +0000 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-08-11 17:40:19 +0000 |
commit | 8a1d584de771b3267374397cc99c019de1c4500c (patch) | |
tree | 5179bb8aaf72c674cb3caff3c96758dc20d82747 | |
parent | 7b44ce1d4a0716d27acabb4f826eb5613dade082 (diff) | |
download | gitlab-shell-8a1d584de771b3267374397cc99c019de1c4500c.tar.gz |
refactor: update usage of NewHTTPClient to NewHTTPClientWithOpts
-rw-r--r-- | client/client_test.go | 3 | ||||
-rw-r--r-- | client/httpclient_test.go | 6 | ||||
-rw-r--r-- | internal/config/config.go | 7 |
3 files changed, 12 insertions, 4 deletions
diff --git a/client/client_test.go b/client/client_test.go index bf45181..f2ecd6c 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -59,7 +59,8 @@ func TestClients(t *testing.T) { secret := "sssh, it's a secret" - httpClient := NewHTTPClient(url, tc.relativeURLRoot, tc.caFile, "", false, 1) + httpClient, err := NewHTTPClientWithOpts(url, tc.relativeURLRoot, tc.caFile, "", false, 1, nil) + require.NoError(t, err) client, err := NewGitlabNetClient("", "", secret, httpClient) require.NoError(t, err) diff --git a/client/httpclient_test.go b/client/httpclient_test.go index 5c1ebe3..f3643a0 100644 --- a/client/httpclient_test.go +++ b/client/httpclient_test.go @@ -17,7 +17,8 @@ import ( func TestReadTimeout(t *testing.T) { expectedSeconds := uint64(300) - client := NewHTTPClient("http://localhost:3000", "", "", "", false, expectedSeconds) + client, err := NewHTTPClientWithOpts("http://localhost:3000", "", "", "", false, expectedSeconds, nil) + require.NoError(t, err) require.NotNil(t, client) require.Equal(t, time.Duration(expectedSeconds)*time.Second, client.Client.Timeout) @@ -122,7 +123,8 @@ func TestRequestWithUserAgent(t *testing.T) { func setup(t *testing.T, username, password string, requests []testserver.TestRequestHandler) *GitlabNetClient { url := testserver.StartHttpServer(t, requests) - httpClient := NewHTTPClient(url, "", "", "", false, 1) + httpClient, err := NewHTTPClientWithOpts(url, "", "", "", false, 1, nil) + require.NoError(t, err) client, err := NewGitlabNetClient(username, password, "", httpClient) require.NoError(t, err) diff --git a/internal/config/config.go b/internal/config/config.go index 5aa99de..41ad7cd 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,6 +15,7 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/client" "gitlab.com/gitlab-org/gitlab-shell/internal/metrics" + "gitlab.com/gitlab-org/labkit/log" ) const ( @@ -97,14 +98,18 @@ func (c *Config) ApplyGlobalState() { func (c *Config) HttpClient() *client.HttpClient { c.httpClientOnce.Do(func() { - client := client.NewHTTPClient( + client, err := client.NewHTTPClientWithOpts( c.GitlabUrl, c.GitlabRelativeURLRoot, c.HttpSettings.CaFile, c.HttpSettings.CaPath, c.HttpSettings.SelfSignedCert, c.HttpSettings.ReadTimeoutSeconds, + nil, ) + if err != nil { + log.WithError(err).Fatal("new http client with opts") + } tr := client.Transport client.Transport = promhttp.InstrumentRoundTripperDuration(metrics.HttpRequestDuration, tr) |