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
f77576bc
Commit
f77576bc
authored
Aug 22, 2016
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Capitalize feature gates
Also rename variables for clarity
parent
6c75bd8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
50 deletions
+50
-50
feature_gate.go
pkg/util/config/feature_gate.go
+7
-7
feature_gate_test.go
pkg/util/config/feature_gate_test.go
+43
-43
No files found.
pkg/util/config/feature_gate.go
View file @
f77576bc
...
...
@@ -33,24 +33,24 @@ const (
// To add a new feature, define a key for it below and add
// a featureSpec entry to knownFeatures.
// allAlpha is a global toggle for alpha features. Per-feature key
// values override the default set by allAlpha, if they come later in the
// allAlpha
Gate
is a global toggle for alpha features. Per-feature key
// values override the default set by allAlpha
Gate
, if they come later in the
// specification of gates. Examples:
//
allAlpha=false,n
ewFeature=true will result in newFeature=true
//
allAlpha=true,n
ewFeature=false will result in newFeature=false
allAlpha
=
"a
llAlpha"
//
AllAlpha=false,N
ewFeature=true will result in newFeature=true
//
AllAlpha=true,N
ewFeature=false will result in newFeature=false
allAlpha
Gate
=
"A
llAlpha"
)
var
(
// Default values for recorded features. Every new feature gate should be
// represented here.
knownFeatures
=
map
[
string
]
featureSpec
{
allAlpha
:
{
false
,
alpha
},
allAlpha
Gate
:
{
false
,
alpha
},
}
// Special handling for a few gates.
specialFeatures
=
map
[
string
]
func
(
f
*
featureGate
,
val
bool
){
allAlpha
:
setUnsetAlphaGates
,
allAlpha
Gate
:
setUnsetAlphaGates
,
}
// DefaultFeatureGate is a shared global FeatureGate.
...
...
pkg/util/config/feature_gate_test.go
View file @
f77576bc
...
...
@@ -26,8 +26,8 @@ import (
func
TestFeatureGateFlag
(
t
*
testing
.
T
)
{
// gates for testing
const
testAlpha
=
"t
estAlpha"
const
testBeta
=
"t
estBeta"
const
testAlpha
Gate
=
"T
estAlpha"
const
testBeta
Gate
=
"T
estBeta"
tests
:=
[]
struct
{
arg
string
...
...
@@ -37,91 +37,91 @@ func TestFeatureGateFlag(t *testing.T) {
{
arg
:
""
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
false
,
testBeta
:
false
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"fooBarBaz=maybeidk"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
false
,
testBeta
:
false
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
false
,
},
parseError
:
"unrecognized key: fooBarBaz"
,
},
{
arg
:
"
a
llAlpha=false"
,
arg
:
"
A
llAlpha=false"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
false
,
testBeta
:
false
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"
a
llAlpha=true"
,
arg
:
"
A
llAlpha=true"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
true
,
testAlpha
:
true
,
testBeta
:
false
,
allAlpha
Gate
:
true
,
testAlpha
Gate
:
true
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"
a
llAlpha=banana"
,
arg
:
"
A
llAlpha=banana"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
false
,
testBeta
:
false
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
false
,
},
parseError
:
"invalid value of
a
llAlpha"
,
parseError
:
"invalid value of
A
llAlpha"
,
},
{
arg
:
"
allAlpha=false,t
estAlpha=true"
,
arg
:
"
AllAlpha=false,T
estAlpha=true"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
true
,
testBeta
:
false
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
true
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"
testAlpha=true,a
llAlpha=false"
,
arg
:
"
TestAlpha=true,A
llAlpha=false"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
true
,
testBeta
:
false
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
true
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"
allAlpha=true,t
estAlpha=false"
,
arg
:
"
AllAlpha=true,T
estAlpha=false"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
true
,
testAlpha
:
false
,
testBeta
:
false
,
allAlpha
Gate
:
true
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"
testAlpha=false,a
llAlpha=true"
,
arg
:
"
TestAlpha=false,A
llAlpha=true"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
true
,
testAlpha
:
false
,
testBeta
:
false
,
allAlpha
Gate
:
true
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
false
,
},
},
{
arg
:
"
testBeta=true,a
llAlpha=false"
,
arg
:
"
TestBeta=true,A
llAlpha=false"
,
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
testAlpha
:
false
,
testBeta
:
true
,
allAlpha
Gate
:
false
,
testAlpha
Gate
:
false
,
testBeta
Gate
:
true
,
},
},
}
for
i
,
test
:=
range
tests
{
fs
:=
pflag
.
NewFlagSet
(
"testfeaturegateflag"
,
pflag
.
ContinueOnError
)
f
:=
DefaultFeatureGate
f
.
known
[
testAlpha
]
=
featureSpec
{
false
,
alpha
}
f
.
known
[
testBeta
]
=
featureSpec
{
false
,
beta
}
f
.
known
[
testAlpha
Gate
]
=
featureSpec
{
false
,
alpha
}
f
.
known
[
testBeta
Gate
]
=
featureSpec
{
false
,
beta
}
f
.
AddFlag
(
fs
)
err
:=
fs
.
Parse
([]
string
{
fmt
.
Sprintf
(
"--%s=%s"
,
flagName
,
test
.
arg
)})
...
...
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