Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
fea5a8bc
Commit
fea5a8bc
authored
Aug 15, 2017
by
Nikhita Raghunath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FeatureGate: update comments
parent
cf80b91a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
feature_gate.go
...ing/src/k8s.io/apiserver/pkg/util/feature/feature_gate.go
+11
-2
No files found.
staging/src/k8s.io/apiserver/pkg/util/feature/feature_gate.go
View file @
fea5a8bc
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment