From 861102f05940cc71de1c8d008dd20f6e8775ce0c Mon Sep 17 00:00:00 2001 From: Devtools Date: Wed, 2 Oct 2024 08:36:14 +0200 Subject: [PATCH] drop newProxyWithClusterClient function and related unnecessary client creation --- pkg/proxy/proxy.go | 10 ---------- pkg/proxy/proxy_test.go | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 08ded564..a7734067 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -65,7 +65,6 @@ func authorizationEndpointTarget() string { type Proxy struct { app application.Application - cl client.Client tokenParser *auth.TokenParser spaceLister *handlers.SpaceLister metrics *metrics.ProxyMetrics @@ -73,14 +72,6 @@ type Proxy struct { } func NewProxy(app application.Application, proxyMetrics *metrics.ProxyMetrics, getMembersFunc commoncluster.GetMemberClustersFunc) (*Proxy, error) { - cl, err := newClusterClient() - if err != nil { - return nil, err - } - return newProxyWithClusterClient(app, cl, proxyMetrics, getMembersFunc) -} - -func newProxyWithClusterClient(app application.Application, cln client.Client, proxyMetrics *metrics.ProxyMetrics, getMembersFunc commoncluster.GetMemberClustersFunc) (*Proxy, error) { tokenParser, err := auth.DefaultTokenParser() if err != nil { return nil, err @@ -90,7 +81,6 @@ func newProxyWithClusterClient(app application.Application, cln client.Client, p spaceLister := handlers.NewSpaceLister(app, proxyMetrics) return &Proxy{ app: app, - cl: cln, tokenParser: tokenParser, spaceLister: spaceLister, metrics: proxyMetrics, diff --git a/pkg/proxy/proxy_test.go b/pkg/proxy/proxy_test.go index 52dcba0a..46d8fe13 100644 --- a/pkg/proxy/proxy_test.go +++ b/pkg/proxy/proxy_test.go @@ -109,7 +109,7 @@ func (s *TestProxySuite) TestProxy() { InformerServiceMock: inf, } proxyMetrics := metrics.NewProxyMetrics(prometheus.NewRegistry()) - p, err := newProxyWithClusterClient(fakeApp, nil, proxyMetrics, proxytest.NewGetMembersFunc(commontest.NewFakeClient(s.T()))) + p, err := NewProxy(fakeApp, proxyMetrics, proxytest.NewGetMembersFunc(commontest.NewFakeClient(s.T()))) require.NoError(s.T(), err) server := p.StartProxy(DefaultPort) @@ -135,8 +135,8 @@ func (s *TestProxySuite) TestProxy() { func (s *TestProxySuite) spinUpProxy(fakeApp *fake.ProxyFakeApp, port string) (*Proxy, *http.Server) { proxyMetrics := metrics.NewProxyMetrics(prometheus.NewRegistry()) - p, err := newProxyWithClusterClient( - fakeApp, nil, proxyMetrics, proxytest.NewGetMembersFunc(commontest.NewFakeClient(s.T()))) + p, err := NewProxy( + fakeApp, proxyMetrics, proxytest.NewGetMembersFunc(commontest.NewFakeClient(s.T()))) require.NoError(s.T(), err) server := p.StartProxy(port)