mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-05 09:01:06 +00:00
client-go/features: introduce feature gates
This PR add a feature gates mechanisim to client-go as described in https://docs.google.com/document/d/1g9BGCRw-7ucUxO6OtCWbb3lfzUGA_uU9178wLdXAIfs In particular: - Adds a default feature gate implementation based on environment variables. - Adds a set of methods for reading, overwriting the default implementation, and adding features to an external registry. Co-authored-by: deads2k <deads@redhat.com> Co-authored-by: Ben Luddy <bluddy@redhat.com> Kubernetes-commit: d74c57d4f592d20a992afb54b1ee64f56215210e
This commit is contained in:
committed by
Kubernetes Publisher
parent
5a0a424792
commit
ca4f3a73f7
40
features/features_test.go
Normal file
40
features/features_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package features
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestAddFeaturesToExistingFeatureGates ensures that
|
||||
// the defaultKubernetesFeatureGates are added to a test feature gates registry.
|
||||
func TestAddFeaturesToExistingFeatureGates(t *testing.T) {
|
||||
fakeFeatureGates := &fakeRegistry{}
|
||||
require.NoError(t, AddFeaturesToExistingFeatureGates(fakeFeatureGates))
|
||||
require.Equal(t, defaultKubernetesFeatureGates, fakeFeatureGates.specs)
|
||||
}
|
||||
|
||||
type fakeRegistry struct {
|
||||
specs map[Feature]FeatureSpec
|
||||
}
|
||||
|
||||
func (f *fakeRegistry) Add(specs map[Feature]FeatureSpec) error {
|
||||
f.specs = specs
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user