mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
use reflect.deepEqual for noop object comparison
This commit is contained in:
parent
9c44ba22ca
commit
63440fef78
@ -19,6 +19,7 @@ package legacyregistry
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@ -98,7 +99,7 @@ func Register(c metrics.KubeCollector) error {
|
|||||||
globalRegistryFactory.registrationLock.Lock()
|
globalRegistryFactory.registrationLock.Lock()
|
||||||
defer globalRegistryFactory.registrationLock.Unlock()
|
defer globalRegistryFactory.registrationLock.Unlock()
|
||||||
|
|
||||||
if globalRegistryFactory.globalRegistry == (noopRegistry{}) {
|
if reflect.DeepEqual(globalRegistryFactory.globalRegistry, noopRegistry{}) {
|
||||||
globalRegistryFactory.registerQueue = append(globalRegistryFactory.registerQueue, c)
|
globalRegistryFactory.registerQueue = append(globalRegistryFactory.registerQueue, c)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -113,7 +114,7 @@ func MustRegister(cs ...metrics.KubeCollector) {
|
|||||||
globalRegistryFactory.registrationLock.Lock()
|
globalRegistryFactory.registrationLock.Lock()
|
||||||
defer globalRegistryFactory.registrationLock.Unlock()
|
defer globalRegistryFactory.registrationLock.Unlock()
|
||||||
|
|
||||||
if globalRegistryFactory.globalRegistry == (noopRegistry{}) {
|
if reflect.DeepEqual(globalRegistryFactory.globalRegistry, noopRegistry{}) {
|
||||||
for _, c := range cs {
|
for _, c := range cs {
|
||||||
globalRegistryFactory.mustRegisterQueue = append(globalRegistryFactory.mustRegisterQueue, c)
|
globalRegistryFactory.mustRegisterQueue = append(globalRegistryFactory.mustRegisterQueue, c)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user