Make genericapiserver.PostStartHooks private

pull/6/head
Dr. Stefan Schimanski 2016-09-22 12:38:47 +02:00
parent 5af04d1dd1
commit 34365c1edd
2 changed files with 6 additions and 6 deletions

View File

@ -169,7 +169,7 @@ type GenericAPIServer struct {
// PostStartHooks are each called after the server has started listening, in a separate go func for each
// with no guaranteee of ordering between them. The map key is a name used for error reporting.
// It may kill the process with a panic if it wishes to by returning an error
PostStartHooks map[string]PostStartHookFunc
postStartHooks map[string]PostStartHookFunc
postStartHookLock sync.Mutex
postStartHooksCalled bool
openAPIDefinitions *common.OpenAPIDefinitions

View File

@ -61,14 +61,14 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
if s.postStartHooksCalled {
return fmt.Errorf("unable to add %q because PostStartHooks have already been called", name)
}
if s.PostStartHooks == nil {
s.PostStartHooks = map[string]PostStartHookFunc{}
if s.postStartHooks == nil {
s.postStartHooks = map[string]PostStartHookFunc{}
}
if _, exists := s.PostStartHooks[name]; exists {
if _, exists := s.postStartHooks[name]; exists {
return fmt.Errorf("unable to add %q because it is already registered", name)
}
s.PostStartHooks[name] = hook
s.postStartHooks[name] = hook
return nil
}
@ -79,7 +79,7 @@ func (s *GenericAPIServer) RunPostStartHooks(context PostStartHookContext) {
defer s.postStartHookLock.Unlock()
s.postStartHooksCalled = true
for hookName, hook := range s.PostStartHooks {
for hookName, hook := range s.postStartHooks {
go runPostStartHook(hookName, hook, context)
}
}