go1.19: change some atomic.Value to atomic.Bool
Signed-off-by: Abirdcfly <fp544037857@gmail.com> Kubernetes-commit: 1d631f7eef4db32afe23460843c4084ed3a3f6bd
This commit is contained in:
parent
b54f08dbf6
commit
487ade9f5d
|
@ -36,11 +36,11 @@ type mutatingWebhookConfigurationManager struct {
|
|||
configuration *atomic.Value
|
||||
lister admissionregistrationlisters.MutatingWebhookConfigurationLister
|
||||
hasSynced func() bool
|
||||
// initialConfigurationSynced stores a boolean value, which tracks if
|
||||
// initialConfigurationSynced tracks if
|
||||
// the existing webhook configs have been synced (honored) by the
|
||||
// manager at startup-- the informer has synced and either has no items
|
||||
// or has finished executing updateConfiguration() once.
|
||||
initialConfigurationSynced *atomic.Value
|
||||
initialConfigurationSynced *atomic.Bool
|
||||
}
|
||||
|
||||
var _ generic.Source = &mutatingWebhookConfigurationManager{}
|
||||
|
@ -51,7 +51,7 @@ func NewMutatingWebhookConfigurationManager(f informers.SharedInformerFactory) g
|
|||
configuration: &atomic.Value{},
|
||||
lister: informer.Lister(),
|
||||
hasSynced: informer.Informer().HasSynced,
|
||||
initialConfigurationSynced: &atomic.Value{},
|
||||
initialConfigurationSynced: &atomic.Bool{},
|
||||
}
|
||||
|
||||
// Start with an empty list
|
||||
|
@ -80,7 +80,7 @@ func (m *mutatingWebhookConfigurationManager) HasSynced() bool {
|
|||
if !m.hasSynced() {
|
||||
return false
|
||||
}
|
||||
if m.initialConfigurationSynced.Load().(bool) {
|
||||
if m.initialConfigurationSynced.Load() {
|
||||
// the informer has synced and configuration has been updated
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ type validatingWebhookConfigurationManager struct {
|
|||
configuration *atomic.Value
|
||||
lister admissionregistrationlisters.ValidatingWebhookConfigurationLister
|
||||
hasSynced func() bool
|
||||
// initialConfigurationSynced stores a boolean value, which tracks if
|
||||
// initialConfigurationSynced tracks if
|
||||
// the existing webhook configs have been synced (honored) by the
|
||||
// manager at startup-- the informer has synced and either has no items
|
||||
// or has finished executing updateConfiguration() once.
|
||||
initialConfigurationSynced *atomic.Value
|
||||
initialConfigurationSynced *atomic.Bool
|
||||
}
|
||||
|
||||
var _ generic.Source = &validatingWebhookConfigurationManager{}
|
||||
|
@ -51,7 +51,7 @@ func NewValidatingWebhookConfigurationManager(f informers.SharedInformerFactory)
|
|||
configuration: &atomic.Value{},
|
||||
lister: informer.Lister(),
|
||||
hasSynced: informer.Informer().HasSynced,
|
||||
initialConfigurationSynced: &atomic.Value{},
|
||||
initialConfigurationSynced: &atomic.Bool{},
|
||||
}
|
||||
|
||||
// Start with an empty list
|
||||
|
@ -80,7 +80,7 @@ func (v *validatingWebhookConfigurationManager) HasSynced() bool {
|
|||
if !v.hasSynced() {
|
||||
return false
|
||||
}
|
||||
if v.initialConfigurationSynced.Load().(bool) {
|
||||
if v.initialConfigurationSynced.Load() {
|
||||
// the informer has synced and configuration has been updated
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -52,10 +52,10 @@ func ListerFuncForResourceFunc(f InformerForResourceFunc) quota.ListerForResourc
|
|||
|
||||
// cachedHasSynced returns a function that calls hasSynced() until it returns true once, then returns true
|
||||
func cachedHasSynced(hasSynced func() bool) func() bool {
|
||||
cache := &atomic.Value{}
|
||||
cache := &atomic.Bool{}
|
||||
cache.Store(false)
|
||||
return func() bool {
|
||||
if cache.Load().(bool) {
|
||||
if cache.Load() {
|
||||
// short-circuit if already synced
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ var _ Manager = &defaultManager{}
|
|||
|
||||
// defaultManager indicates if an apiserver has completed reporting its storage versions.
|
||||
type defaultManager struct {
|
||||
completed atomic.Value
|
||||
completed atomic.Bool
|
||||
|
||||
mu sync.RWMutex
|
||||
// managedResourceInfos records the ResourceInfos whose StorageVersions will get updated in the next
|
||||
|
@ -268,7 +268,7 @@ func (s *defaultManager) setComplete() {
|
|||
|
||||
// Completed returns if updating StorageVersions has completed.
|
||||
func (s *defaultManager) Completed() bool {
|
||||
return s.completed.Load().(bool)
|
||||
return s.completed.Load()
|
||||
}
|
||||
|
||||
func decodableVersions(directlyDecodableVersions []schema.GroupVersion, e runtime.EquivalentResourceRegistry, gr schema.GroupResource) []string {
|
||||
|
|
Loading…
Reference in New Issue