mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-30 04:26:44 +00:00
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
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
/*
|
|
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
|
|
}
|