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
Show 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 (
...
@@ -33,24 +33,24 @@ const (
// To add a new feature, define a key for it below and add
// To add a new feature, define a key for it below and add
// a featureSpec entry to knownFeatures.
// a featureSpec entry to knownFeatures.
// allAlpha is a global toggle for alpha features. Per-feature key
// allAlpha
Gate
is a global toggle for alpha features. Per-feature key
// values override the default set by allAlpha, if they come later in the
// values override the default set by allAlpha
Gate
, if they come later in the
// specification of gates. Examples:
// specification of gates. Examples:
//
allAlpha=false,n
ewFeature=true will result in newFeature=true
//
AllAlpha=false,N
ewFeature=true will result in newFeature=true
//
allAlpha=true,n
ewFeature=false will result in newFeature=false
//
AllAlpha=true,N
ewFeature=false will result in newFeature=false
allAlpha
=
"a
llAlpha"
allAlpha
Gate
=
"A
llAlpha"
)
)
var
(
var
(
// Default values for recorded features. Every new feature gate should be
// Default values for recorded features. Every new feature gate should be
// represented here.
// represented here.
knownFeatures
=
map
[
string
]
featureSpec
{
knownFeatures
=
map
[
string
]
featureSpec
{
allAlpha
:
{
false
,
alpha
},
allAlpha
Gate
:
{
false
,
alpha
},
}
}
// Special handling for a few gates.
// Special handling for a few gates.
specialFeatures
=
map
[
string
]
func
(
f
*
featureGate
,
val
bool
){
specialFeatures
=
map
[
string
]
func
(
f
*
featureGate
,
val
bool
){
allAlpha
:
setUnsetAlphaGates
,
allAlpha
Gate
:
setUnsetAlphaGates
,
}
}
// DefaultFeatureGate is a shared global FeatureGate.
// DefaultFeatureGate is a shared global FeatureGate.
...
...
pkg/util/config/feature_gate_test.go
View file @
f77576bc
...
@@ -26,8 +26,8 @@ import (
...
@@ -26,8 +26,8 @@ import (
func
TestFeatureGateFlag
(
t
*
testing
.
T
)
{
func
TestFeatureGateFlag
(
t
*
testing
.
T
)
{
// gates for testing
// gates for testing
const
testAlpha
=
"t
estAlpha"
const
testAlpha
Gate
=
"T
estAlpha"
const
testBeta
=
"t
estBeta"
const
testBeta
Gate
=
"T
estBeta"
tests
:=
[]
struct
{
tests
:=
[]
struct
{
arg
string
arg
string
...
@@ -37,91 +37,91 @@ func TestFeatureGateFlag(t *testing.T) {
...
@@ -37,91 +37,91 @@ func TestFeatureGateFlag(t *testing.T) {
{
{
arg
:
""
,
arg
:
""
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"fooBarBaz=maybeidk"
,
arg
:
"fooBarBaz=maybeidk"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
parseError
:
"unrecognized key: fooBarBaz"
,
parseError
:
"unrecognized key: fooBarBaz"
,
},
},
{
{
arg
:
"
a
llAlpha=false"
,
arg
:
"
A
llAlpha=false"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"
a
llAlpha=true"
,
arg
:
"
A
llAlpha=true"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
true
,
allAlpha
Gate
:
true
,
testAlpha
:
true
,
testAlpha
Gate
:
true
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"
a
llAlpha=banana"
,
arg
:
"
A
llAlpha=banana"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
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
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
true
,
testAlpha
Gate
:
true
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"
testAlpha=true,a
llAlpha=false"
,
arg
:
"
TestAlpha=true,A
llAlpha=false"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
true
,
testAlpha
Gate
:
true
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"
allAlpha=true,t
estAlpha=false"
,
arg
:
"
AllAlpha=true,T
estAlpha=false"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
true
,
allAlpha
Gate
:
true
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"
testAlpha=false,a
llAlpha=true"
,
arg
:
"
TestAlpha=false,A
llAlpha=true"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
true
,
allAlpha
Gate
:
true
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
false
,
testBeta
Gate
:
false
,
},
},
},
},
{
{
arg
:
"
testBeta=true,a
llAlpha=false"
,
arg
:
"
TestBeta=true,A
llAlpha=false"
,
expect
:
map
[
string
]
bool
{
expect
:
map
[
string
]
bool
{
allAlpha
:
false
,
allAlpha
Gate
:
false
,
testAlpha
:
false
,
testAlpha
Gate
:
false
,
testBeta
:
true
,
testBeta
Gate
:
true
,
},
},
},
},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
fs
:=
pflag
.
NewFlagSet
(
"testfeaturegateflag"
,
pflag
.
ContinueOnError
)
fs
:=
pflag
.
NewFlagSet
(
"testfeaturegateflag"
,
pflag
.
ContinueOnError
)
f
:=
DefaultFeatureGate
f
:=
DefaultFeatureGate
f
.
known
[
testAlpha
]
=
featureSpec
{
false
,
alpha
}
f
.
known
[
testAlpha
Gate
]
=
featureSpec
{
false
,
alpha
}
f
.
known
[
testBeta
]
=
featureSpec
{
false
,
beta
}
f
.
known
[
testBeta
Gate
]
=
featureSpec
{
false
,
beta
}
f
.
AddFlag
(
fs
)
f
.
AddFlag
(
fs
)
err
:=
fs
.
Parse
([]
string
{
fmt
.
Sprintf
(
"--%s=%s"
,
flagName
,
test
.
arg
)})
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