From a9c86ae565f7990460b9543a4402d42b24893dd8 Mon Sep 17 00:00:00 2001 From: Anthony J Mirabella Date: Thu, 18 Nov 2021 12:15:25 -0500 Subject: [PATCH] Revert "Add accessor for global feature gate registry" This reverts commit 23c957c166d300ecb0ae546e82cae4aeffb36728. --- service/featuregate/gates.go | 11 ----------- service/featuregate/gates_test.go | 4 ---- 2 files changed, 15 deletions(-) diff --git a/service/featuregate/gates.go b/service/featuregate/gates.go index 2d81a91fcfd..b45d3ca7705 100644 --- a/service/featuregate/gates.go +++ b/service/featuregate/gates.go @@ -53,18 +53,11 @@ func Apply(cfg map[string]bool) { reg.Apply(cfg) } -// GlobalRegistry returns the Registry instance used by package-global functions in this package. -func GlobalRegistry() *Registry { - return reg -} - type Registry struct { sync.RWMutex gates map[string]Gate } -// Apply a configuration in the form of a map of Gate identifiers to boolean values. -// Sets only those values provided in the map, other gate values are not changed. func (r *Registry) Apply(cfg map[string]bool) { r.Lock() defer r.Unlock() @@ -76,8 +69,6 @@ func (r *Registry) Apply(cfg map[string]bool) { } } -// Add a Gate. May only be called in an init() function. -// Returns an error if a Gate with the same ID is already registered. func (r *Registry) Add(g Gate) error { r.Lock() defer r.Unlock() @@ -89,7 +80,6 @@ func (r *Registry) Add(g Gate) error { return nil } -// IsEnabled returns true if a registered feature gate is enabled and false otherwise. func (r *Registry) IsEnabled(id string) bool { r.RLock() defer r.RUnlock() @@ -97,7 +87,6 @@ func (r *Registry) IsEnabled(id string) bool { return ok && g.Enabled } -// List returns a slice of copies of all registered Gates. func (r *Registry) List() []Gate { r.RLock() defer r.RUnlock() diff --git a/service/featuregate/gates_test.go b/service/featuregate/gates_test.go index c6498660b5b..4488b8002d3 100644 --- a/service/featuregate/gates_test.go +++ b/service/featuregate/gates_test.go @@ -51,17 +51,13 @@ func TestGlobalRegistry(t *testing.T) { assert.NotContains(t, List(), gate) assert.False(t, IsEnabled(gate.ID)) - assert.False(t, GlobalRegistry().IsEnabled(gate.ID)) assert.NotPanics(t, func() { Register(gate) }) assert.Contains(t, List(), gate) - assert.Contains(t, GlobalRegistry().List(), gate) assert.True(t, IsEnabled(gate.ID)) - assert.True(t, GlobalRegistry().IsEnabled(gate.ID)) Apply(map[string]bool{gate.ID: false}) assert.False(t, IsEnabled(gate.ID)) - assert.False(t, GlobalRegistry().IsEnabled(gate.ID)) assert.Panics(t, func() { Register(gate) }) reg.Lock()