Add an OrDie version for AddPostStartHook

Simplifies usage and consolidate the error message so it is always
the same everywhere.

Signed-off-by: Simo Sorce <simo@redhat.com>

Kubernetes-commit: 15c54ffa7750c3037f464933c2b678a9a94cea82
This commit is contained in:
Simo Sorce 2017-08-23 11:06:29 -04:00 committed by Kubernetes Publisher
parent 3be1849274
commit 91f15f8472
1 changed files with 7 additions and 0 deletions

View File

@ -90,6 +90,13 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
return nil
}
// AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure
func (s *GenericAPIServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc) {
if err := s.AddPostStartHook(name, hook); err != nil {
glog.Fatalf("Error registering PostStartHook %q: %v", name, err)
}
}
// RunPostStartHooks runs the PostStartHooks for the server
func (s *GenericAPIServer) RunPostStartHooks(stopCh <-chan struct{}) {
s.postStartHookLock.Lock()