Skip to content

Commit d26f72a

Browse files
authored
feat: Add feature-gates plumbing (#919)
This will be used by upcoming experimental features such as in-cluster registry. Just adding the plumbing for now. **What problem does this PR solve?**: **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent d978243 commit d26f72a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cmd/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1414
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
1515
cliflag "k8s.io/component-base/cli/flag"
16+
"k8s.io/component-base/featuregate"
1617
"k8s.io/component-base/logs"
1718
logsv1 "k8s.io/component-base/logs/api/v1"
1819
"k8s.io/component-base/version/verflag"
@@ -32,6 +33,7 @@ import (
3233
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers"
3334
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/server"
3435
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync"
36+
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/features"
3537
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws"
3638
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker"
3739
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic"
@@ -127,6 +129,12 @@ func main() {
127129
namespacesyncOptions.AddFlags(pflag.CommandLine)
128130
pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
129131
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
132+
133+
// Add feature gate flags.
134+
featureGate := featuregate.NewFeatureGate()
135+
utilruntime.Must(featureGate.Add(features.DefaultFeatureGates()))
136+
featureGate.AddFlag(pflag.CommandLine)
137+
130138
pflag.Parse()
131139

132140
verflag.PrintAndExitIfRequested()

pkg/features/feature_gates.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2024 Nutanix. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package features
5+
6+
import "k8s.io/component-base/featuregate"
7+
8+
// DefaultFeatureGates returns all known feature gates.
9+
// To add a new feature, define a key for it above and add it here. The features will be
10+
// available throughout the codebase.
11+
func DefaultFeatureGates() map[featuregate.Feature]featuregate.FeatureSpec {
12+
return map[featuregate.Feature]featuregate.FeatureSpec{}
13+
}

0 commit comments

Comments
 (0)