Skip to content

Commit ffd22fa

Browse files
authored
feat: add Redis Proxy disable option for test environment (#607)
Signed-off-by: yeonsoo <[email protected]>
1 parent 4f36ea7 commit ffd22fa

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

principal/options.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type ServerOptions struct {
7575
redisPassword string
7676
redisCompressionType cacheutil.RedisCompressionType
7777
healthzPort int
78+
redisProxyDisabled bool
7879
informerSyncTimeout time.Duration
7980
}
8081

@@ -417,6 +418,14 @@ func WithWebSocket(enableWebSocket bool) ServerOption {
417418
}
418419
}
419420

421+
// WithRedisProxyDisabled disables the Redis proxy for testing.
422+
func WithRedisProxyDisabled() ServerOption {
423+
return func(o *Server) error {
424+
o.options.redisProxyDisabled = true
425+
return nil
426+
}
427+
}
428+
420429
// WithInformerSyncTimeout sets the informer sync timeout duration.
421430
func WithInformerSyncTimeout(timeout time.Duration) ServerOption {
422431
return func(o *Server) error {

principal/options_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ func Test_WithMinimumTLSVersion(t *testing.T) {
9898
}
9999
})
100100
}
101+
102+
func Test_WithRedisProxyDisabled(t *testing.T) {
103+
s := &Server{options: &ServerOptions{}}
104+
err := WithRedisProxyDisabled()(s)
105+
assert.NoError(t, err)
106+
assert.True(t, s.options.redisProxyDisabled)
107+
}

principal/server.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ func NewServer(ctx context.Context, kubeClient *kube.KubernetesClient, namespace
337337
s.resourceProxyListenAddr = defaultResourceProxyListenerAddr
338338
}
339339

340-
s.redisProxy = redisproxy.New(defaultRedisProxyListenerAddr, s.options.redisAddress, s.sendSynchronousRedisMessageToAgent)
340+
if !s.options.redisProxyDisabled {
341+
s.redisProxy = redisproxy.New(defaultRedisProxyListenerAddr, s.options.redisAddress, s.sendSynchronousRedisMessageToAgent)
342+
}
341343

342344
// Instantiate our ResourceProxy to intercept Kubernetes requests from Argo
343345
// CD's API server.

0 commit comments

Comments
 (0)