Skip to content

Commit

Permalink
checking for empty name namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tvoran committed Sep 14, 2024
1 parent 5812639 commit 6dfeb48
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions controllers/vaultstaticsecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit 6dfeb48

Please sign in to comment.