From 6dfeb483a66b83743d017633b76d33b7614caf45 Mon Sep 17 00:00:00 2001 From: Theron Voran Date: Fri, 13 Sep 2024 17:35:57 -0700 Subject: [PATCH] checking for empty name namespace --- controllers/vaultstaticsecret_controller.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/controllers/vaultstaticsecret_controller.go b/controllers/vaultstaticsecret_controller.go index 0d4dff6e..cf3c3b05 100644 --- a/controllers/vaultstaticsecret_controller.go +++ b/controllers/vaultstaticsecret_controller.go @@ -295,6 +295,9 @@ func (r *VaultStaticSecretReconciler) ensureEventWatcher(ctx context.Context, o r.eventWatcherRegistry.Register(name, updatedMeta) // Pass a dereferenced VSS object here to avoid the effect of the VSS object // being garbage collected before the goroutine is started/evaluated + if o.Namespace == "" || o.Name == "" { + return fmt.Errorf("empty namespace or name") + } wg := &sync.WaitGroup{} wg.Add(1) go r.getEvents(watchCtx, o, wsClient, stoppedCh, wg) @@ -321,8 +324,8 @@ func (r *VaultStaticSecretReconciler) unWatchEvents(o *secretsv1beta1.VaultStati func (r *VaultStaticSecretReconciler) getEvents(ctx context.Context, o *secretsv1beta1.VaultStaticSecret, wsClient *vault.WebsocketClient, stoppedCh chan struct{}, wg *sync.WaitGroup) { wg.Done() logger := log.FromContext(ctx).WithName("getEvents") - if o == nil { - logger.Error(fmt.Errorf("nil VaultStaticSecret object"), "nil VaultStaticSecret object") + if o.Namespace == "" || o.Name == "" { + logger.Error(fmt.Errorf("empty namespace or name"), "Empty namespace or name, stopping getEvents") close(stoppedCh) return }