mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #50638 from nikhita/feature-gates-doc
Automatic merge from submit-queue FeatureGate: update comments The godoc - https://godoc.org/k8s.io/apiserver/pkg/util/feature - does not contain descriptions of the functions. This PR adds them. **Release note**: ```release-note NONE ``` /cc @sttts
This commit is contained in:
commit
1268c1a1e0
@ -70,10 +70,16 @@ const (
|
|||||||
// FeatureGate parses and stores flag gates for known features from
|
// FeatureGate parses and stores flag gates for known features from
|
||||||
// a string like feature1=true,feature2=false,...
|
// a string like feature1=true,feature2=false,...
|
||||||
type FeatureGate interface {
|
type FeatureGate interface {
|
||||||
|
// AddFlag adds a flag for setting global feature gates to the specified FlagSet.
|
||||||
AddFlag(fs *pflag.FlagSet)
|
AddFlag(fs *pflag.FlagSet)
|
||||||
|
// Set parses and stores flag gates for known features
|
||||||
|
// from a string like feature1=true,feature2=false,...
|
||||||
Set(value string) error
|
Set(value string) error
|
||||||
|
// Enabled returns true if the key is enabled.
|
||||||
Enabled(key Feature) bool
|
Enabled(key Feature) bool
|
||||||
|
// Add adds features to the featureGate.
|
||||||
Add(features map[Feature]FeatureSpec) error
|
Add(features map[Feature]FeatureSpec) error
|
||||||
|
// KnownFeatures returns a slice of strings describing the FeatureGate's known features.
|
||||||
KnownFeatures() []string
|
KnownFeatures() []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +118,7 @@ func NewFeatureGate() *featureGate {
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Parses a string of the form // "key1=value1,key2=value2,..." into a
|
// Set Parses a string of the form "key1=value1,key2=value2,..." into a
|
||||||
// map[string]bool of known keys or returns an error.
|
// map[string]bool of known keys or returns an error.
|
||||||
func (f *featureGate) Set(value string) error {
|
func (f *featureGate) Set(value string) error {
|
||||||
for _, s := range strings.Split(value, ",") {
|
for _, s := range strings.Split(value, ",") {
|
||||||
@ -145,6 +151,7 @@ func (f *featureGate) Set(value string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a string containing all enabled feature gates, formatted as "key1=value1,key2=value2,...".
|
||||||
func (f *featureGate) String() string {
|
func (f *featureGate) String() string {
|
||||||
pairs := []string{}
|
pairs := []string{}
|
||||||
for k, v := range f.enabled {
|
for k, v := range f.enabled {
|
||||||
@ -158,6 +165,7 @@ func (f *featureGate) Type() string {
|
|||||||
return "mapStringBool"
|
return "mapStringBool"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add adds features to the featureGate.
|
||||||
func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
|
func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
|
||||||
if f.closed {
|
if f.closed {
|
||||||
return fmt.Errorf("cannot add a feature gate after adding it to the flag set")
|
return fmt.Errorf("cannot add a feature gate after adding it to the flag set")
|
||||||
@ -176,6 +184,7 @@ func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enabled returns true if the key is enabled.
|
||||||
func (f *featureGate) Enabled(key Feature) bool {
|
func (f *featureGate) Enabled(key Feature) bool {
|
||||||
defaultValue := f.known[key].Default
|
defaultValue := f.known[key].Default
|
||||||
if f.enabled != nil {
|
if f.enabled != nil {
|
||||||
@ -196,7 +205,7 @@ func (f *featureGate) AddFlag(fs *pflag.FlagSet) {
|
|||||||
"Options are:\n"+strings.Join(known, "\n"))
|
"Options are:\n"+strings.Join(known, "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string describing the FeatureGate's known features.
|
// KnownFeatures returns a slice of strings describing the FeatureGate's known features.
|
||||||
func (f *featureGate) KnownFeatures() []string {
|
func (f *featureGate) KnownFeatures() []string {
|
||||||
var known []string
|
var known []string
|
||||||
for k, v := range f.known {
|
for k, v := range f.known {
|
||||||
|
Loading…
Reference in New Issue
Block a user