prevent nil pointer when starting controllers before running the shared informer

This commit is contained in:
deads2k
2016-05-16 09:53:45 -04:00
parent 8d90427c34
commit 4af1c546b4

View File

@@ -139,11 +139,12 @@ func (s *sharedIndexInformer) Run(stopCh <-chan struct{}) {
Process: s.HandleDeltas,
}
s.controller = New(cfg)
func() {
s.startedLock.Lock()
defer s.startedLock.Unlock()
s.controller = New(cfg)
s.started = true
}()
@@ -158,6 +159,12 @@ func (s *sharedIndexInformer) isStarted() bool {
}
func (s *sharedIndexInformer) HasSynced() bool {
s.startedLock.Lock()
defer s.startedLock.Unlock()
if s.controller == nil {
return false
}
return s.controller.HasSynced()
}