diff --git a/cmd/main.go b/cmd/main.go index f48ce6fbf..4cc73c3ce 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -13,6 +13,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" cliflag "k8s.io/component-base/cli/flag" + "k8s.io/component-base/featuregate" "k8s.io/component-base/logs" logsv1 "k8s.io/component-base/logs/api/v1" "k8s.io/component-base/version/verflag" @@ -32,6 +33,7 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/server" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync" + "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/features" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic" @@ -127,6 +129,12 @@ func main() { namespacesyncOptions.AddFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + + // Add feature gate flags. + featureGate := featuregate.NewFeatureGate() + utilruntime.Must(featureGate.Add(features.DefaultFeatureGates())) + featureGate.AddFlag(pflag.CommandLine) + pflag.Parse() verflag.PrintAndExitIfRequested() diff --git a/pkg/features/feature_gates.go b/pkg/features/feature_gates.go new file mode 100644 index 000000000..783994298 --- /dev/null +++ b/pkg/features/feature_gates.go @@ -0,0 +1,13 @@ +// Copyright 2024 Nutanix. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package features + +import "k8s.io/component-base/featuregate" + +// DefaultFeatureGates returns all known feature gates. +// To add a new feature, define a key for it above and add it here. The features will be +// available throughout the codebase. +func DefaultFeatureGates() map[featuregate.Feature]featuregate.FeatureSpec { + return map[featuregate.Feature]featuregate.FeatureSpec{} +}