From 9959535b4d2aaded9d161383338804a058a0cdbc Mon Sep 17 00:00:00 2001 From: huabing zhao Date: Mon, 26 Feb 2024 19:53:22 +0800 Subject: [PATCH] fix test Signed-off-by: huabing zhao --- internal/k8s/controller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index 8b45c56..88df4a8 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -96,8 +96,12 @@ func (s *SecretController) Name() string { return "Secret controller" } // The controller manager is encapsulated in the secret controller because we // only need it to watch secrets and update the configuration. func (s *SecretController) ServeContext(ctx context.Context) error { - var err error + // If there are no secrets to watch, we can skip starting the controller manager + if s.secrets.Len() == 0 { + return nil + } + var err error if s.restConf == nil { s.restConf, err = config.GetConfig() if err != nil {