diff --git a/pkg/client/client.go b/pkg/client/client.go index d2d084b..623868a 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -55,6 +55,14 @@ func AddToScheme() error { var DefaultNewClient = NewClient func NewClient(token, apiEndpoint string) (runtimeclient.Client, error) { + return NewClientWithTransport(token, apiEndpoint, &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, // nolint: gosec + }, + }) +} + +func NewClientWithTransport(token, apiEndpoint string, transport http.RoundTripper) (runtimeclient.Client, error) { if err := AddToScheme(); err != nil { return nil, err } @@ -63,11 +71,7 @@ func NewClient(token, apiEndpoint string) (runtimeclient.Client, error) { return nil, err } - cfg.Transport = &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, // nolint: gosec - }, - } + cfg.Transport = transport cfg.BearerToken = string(token) cfg.QPS = 40.0 cfg.Burst = 50 diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 5c30fdc..017589e 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -26,14 +26,14 @@ import ( func TestNewClientOK(t *testing.T) { // given t.Cleanup(gock.OffAll) - gock.New("http://example.com"). + gock.New("https://some-dummy-example.com"). Get("api"). Persist(). Reply(200). BodyString("{}") // when - cl, err := client.NewClient("cool-token", "http://example.com") + cl, err := client.NewClientWithTransport("cool-token", "https://some-dummy-example.com", gock.DefaultTransport) // then require.NoError(t, err)