...
1
16
17 package features
18
19 import (
20 "fmt"
21
22 clientfeatures "k8s.io/client-go/features"
23 "k8s.io/component-base/featuregate"
24 )
25
26
27
28
29
30
31
32 type clientAdapter struct {
33 mfg featuregate.MutableFeatureGate
34 }
35
36 var _ clientfeatures.Gates = &clientAdapter{}
37
38 func (a *clientAdapter) Enabled(name clientfeatures.Feature) bool {
39 return a.mfg.Enabled(featuregate.Feature(name))
40 }
41
42 var _ clientfeatures.Registry = &clientAdapter{}
43
44 func (a *clientAdapter) Add(in map[clientfeatures.Feature]clientfeatures.FeatureSpec) error {
45 out := map[featuregate.Feature]featuregate.FeatureSpec{}
46 for name, spec := range in {
47 converted := featuregate.FeatureSpec{
48 Default: spec.Default,
49 LockToDefault: spec.LockToDefault,
50 }
51 switch spec.PreRelease {
52 case clientfeatures.Alpha:
53 converted.PreRelease = featuregate.Alpha
54 case clientfeatures.Beta:
55 converted.PreRelease = featuregate.Beta
56 case clientfeatures.GA:
57 converted.PreRelease = featuregate.GA
58 case clientfeatures.Deprecated:
59 converted.PreRelease = featuregate.Deprecated
60 default:
61
62
63
64 panic(fmt.Sprintf("unrecognized prerelease %q of feature %q", spec.PreRelease, name))
65 }
66 out[featuregate.Feature(name)] = converted
67 }
68 return a.mfg.Add(out)
69 }
70
View as plain text