mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Make genericapiserver.PostStartHooks private
This commit is contained in:
parent
5af04d1dd1
commit
34365c1edd
@ -169,7 +169,7 @@ type GenericAPIServer struct {
|
|||||||
// PostStartHooks are each called after the server has started listening, in a separate go func for each
|
// 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.
|
// 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
|
// 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
|
postStartHookLock sync.Mutex
|
||||||
postStartHooksCalled bool
|
postStartHooksCalled bool
|
||||||
openAPIDefinitions *common.OpenAPIDefinitions
|
openAPIDefinitions *common.OpenAPIDefinitions
|
||||||
|
@ -61,14 +61,14 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
|
|||||||
if s.postStartHooksCalled {
|
if s.postStartHooksCalled {
|
||||||
return fmt.Errorf("unable to add %q because PostStartHooks have already been called", name)
|
return fmt.Errorf("unable to add %q because PostStartHooks have already been called", name)
|
||||||
}
|
}
|
||||||
if s.PostStartHooks == nil {
|
if s.postStartHooks == nil {
|
||||||
s.PostStartHooks = map[string]PostStartHookFunc{}
|
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)
|
return fmt.Errorf("unable to add %q because it is already registered", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.PostStartHooks[name] = hook
|
s.postStartHooks[name] = hook
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ func (s *GenericAPIServer) RunPostStartHooks(context PostStartHookContext) {
|
|||||||
defer s.postStartHookLock.Unlock()
|
defer s.postStartHookLock.Unlock()
|
||||||
s.postStartHooksCalled = true
|
s.postStartHooksCalled = true
|
||||||
|
|
||||||
for hookName, hook := range s.PostStartHooks {
|
for hookName, hook := range s.postStartHooks {
|
||||||
go runPostStartHook(hookName, hook, context)
|
go runPostStartHook(hookName, hook, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user