Skip to content

Commit

Permalink
Fix exit conflict with defers
Browse files Browse the repository at this point in the history
Signed-off-by: Keegan Witt <[email protected]>
  • Loading branch information
keeganwitt committed Jan 18, 2024
1 parent 871a56e commit e83e06f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/sidecar/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func New(configPath string, log logrus.FieldLogger) (*Sidecar, error) {
// When a new SVID is received on the updateChan, the SVID certificates
// are stored in disk and a restart signal is sent to the proxy's process
func (s *Sidecar) RunDaemon(ctx context.Context) error {
s.run(ctx)

if s.config.ExitWhenJwtReady {
os.Exit(0)
}

return nil
}

func (s *Sidecar) run(ctx context.Context) {
var wg sync.WaitGroup

if s.config.SvidFileName != "" && s.config.SvidKeyFileName != "" && s.config.SvidBundleFileName != "" {
Expand Down Expand Up @@ -122,12 +132,6 @@ func (s *Sidecar) RunDaemon(ctx context.Context) error {
}

wg.Wait()

if s.config.ExitWhenJwtReady {
os.Exit(0)
}

return nil
}

// CertReadyChan returns a channel to know when the certificates are ready
Expand Down

0 comments on commit e83e06f

Please sign in to comment.