Skip to content

Commit

Permalink
drop newProxyWithClusterClient function and related unnecessary clien…
Browse files Browse the repository at this point in the history
…t creation
  • Loading branch information
MatousJobanek committed Oct 2, 2024
1 parent 6d3e720 commit 861102f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
10 changes: 0 additions & 10 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,13 @@ func authorizationEndpointTarget() string {

type Proxy struct {
app application.Application
cl client.Client
tokenParser *auth.TokenParser
spaceLister *handlers.SpaceLister
metrics *metrics.ProxyMetrics
getMembersFunc commoncluster.GetMemberClustersFunc
}

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
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions pkg/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 861102f

Please sign in to comment.