-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Feature Gates to enable or disable features
There are a number of features that are being developed and likely to be disabled by default in their early stage. Instead of adding a temporary config for each feature and maintaining them separately, this patch introduces Feature Gates to toggle the features. It will be easier to choose code branch based on FeatureGates' "Enabled" method and to promote features to beta and GA.
- Loading branch information
Showing
12 changed files
with
105 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2020 Antrea 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 ( | ||
"k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/component-base/featuregate" | ||
) | ||
|
||
const ( | ||
// Every feature gate should add constant here following this template: | ||
// | ||
// alpha: vX.Y | ||
// beta: vX.Y | ||
// MyFeature featuregate.Feature = "MyFeature" | ||
|
||
// alpha: v0.8 | ||
// Allows to apply cluster-wide NetworkPolicies. | ||
ClusterNetworkPolicy featuregate.Feature = "ClusterNetworkPolicy" | ||
) | ||
|
||
var ( | ||
// DefaultMutableFeatureGate is a mutable version of DefaultFeatureGate. | ||
DefaultMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate() | ||
|
||
// DefaultFeatureGate is a shared global FeatureGate. | ||
// The feature gate should be modified via DefaultMutableFeatureGate. | ||
DefaultFeatureGate featuregate.FeatureGate = DefaultMutableFeatureGate | ||
|
||
// defaultAntreaFeatureGates consists of all known Antrea-specific feature keys. | ||
// To add a new feature, define a key for it above and add it here. The features will be | ||
// available throughout Antrea binaries. | ||
defaultAntreaFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ | ||
ClusterNetworkPolicy: {Default: false, PreRelease: featuregate.Alpha}, | ||
} | ||
) | ||
|
||
func init() { | ||
runtime.Must(DefaultMutableFeatureGate.Add(defaultAntreaFeatureGates)) | ||
} |