mirror of https://github.com/k3s-io/k3s
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 @stttspull/6/head
commit
1268c1a1e0
|
@ -70,10 +70,16 @@ const (
|
|||
// FeatureGate parses and stores flag gates for known features from
|
||||
// a string like feature1=true,feature2=false,...
|
||||
type FeatureGate interface {
|
||||
// AddFlag adds a flag for setting global feature gates to the specified 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
|
||||
// Enabled returns true if the key is enabled.
|
||||
Enabled(key Feature) bool
|
||||
// Add adds features to the featureGate.
|
||||
Add(features map[Feature]FeatureSpec) error
|
||||
// KnownFeatures returns a slice of strings describing the FeatureGate's known features.
|
||||
KnownFeatures() []string
|
||||
}
|
||||
|
||||
|
@ -112,7 +118,7 @@ func NewFeatureGate() *featureGate {
|
|||
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.
|
||||
func (f *featureGate) Set(value string) error {
|
||||
for _, s := range strings.Split(value, ",") {
|
||||
|
@ -145,6 +151,7 @@ func (f *featureGate) Set(value string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// String returns a string containing all enabled feature gates, formatted as "key1=value1,key2=value2,...".
|
||||
func (f *featureGate) String() string {
|
||||
pairs := []string{}
|
||||
for k, v := range f.enabled {
|
||||
|
@ -158,6 +165,7 @@ func (f *featureGate) Type() string {
|
|||
return "mapStringBool"
|
||||
}
|
||||
|
||||
// Add adds features to the featureGate.
|
||||
func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
|
||||
if f.closed {
|
||||
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
|
||||
}
|
||||
|
||||
// Enabled returns true if the key is enabled.
|
||||
func (f *featureGate) Enabled(key Feature) bool {
|
||||
defaultValue := f.known[key].Default
|
||||
if f.enabled != nil {
|
||||
|
@ -196,7 +205,7 @@ func (f *featureGate) AddFlag(fs *pflag.FlagSet) {
|
|||
"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 {
|
||||
var known []string
|
||||
for k, v := range f.known {
|
||||
|
|
Loading…
Reference in New Issue