Skip to content

Commit f7a2360

Browse files
committed
HACK, UNTESTED: suppert external gate providers
1 parent 3ca4e7c commit f7a2360

File tree

3 files changed

+221
-77
lines changed

3 files changed

+221
-77
lines changed

gate_example.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/pflag"
7+
"k8s.io/utils/feature"
8+
)
9+
10+
var (
11+
libGates = &feature.GateSet{}
12+
f1 = libGates.Add(&feature.Gate{
13+
Name: "Feature1",
14+
Default: false,
15+
Release: feature.Alpha,
16+
})
17+
f2 = libGates.Add(&feature.Gate{
18+
Name: "Feature2",
19+
Default: true,
20+
Release: feature.Beta,
21+
})
22+
f3 = libGates.Add(&feature.Gate{
23+
Name: "Feature3",
24+
Default: true,
25+
Release: feature.GA,
26+
LockToDefault: true,
27+
})
28+
f4 = &feature.Gate{
29+
Name: "Feature4",
30+
Default: true,
31+
Release: feature.Beta,
32+
}
33+
)
34+
35+
func main() {
36+
libGates.EnablePFlagControl("gates", pflag.CommandLine)
37+
libGates.EnableEnvControl("GATE_")
38+
pflag.Parse()
39+
fmt.Println(feature.Enabled(f1))
40+
fmt.Println(feature.Enabled(f2))
41+
fmt.Println(feature.Enabled(f3))
42+
fmt.Println(feature.Enabled(f4))
43+
}

staging/src/k8s.io/apiserver/pkg/server/options/server_run_options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,5 +340,6 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
340340
"This option, if set, represents the maximum amount of grace period the apiserver will wait "+
341341
"for active watch request(s) to drain during the graceful server shutdown window.")
342342

343-
s.FeatureGates.AddFlags("new-feature-gates", fs)
343+
s.FeatureGates.EnableFlagControl("new-feature-gates", fs)
344+
s.FeatureGates.EnableEnvControl("KUBE_FEATURE_")
344345
}

0 commit comments

Comments
 (0)