blob: 9be3b35c4ad22d520ce026cdeb8b4490bd1070c4 [file] [log] [blame]
Lorenz Brund58edf42024-11-27 20:38:14 +00001package kubernetes
2
3import (
4 "fmt"
5 "strings"
6
7 "k8s.io/component-base/featuregate"
Lorenz Brun2ecccae2024-11-27 22:03:35 +01008 "k8s.io/kubernetes/pkg/features"
Lorenz Brund58edf42024-11-27 20:38:14 +00009)
10
11type featureGates map[featuregate.Feature]bool
12
13// AsFlag returns the feature gates as a --feature-gate flag.
14func (fgs featureGates) AsFlag() string {
15 var strb strings.Builder
16 strb.WriteString("--feature-gates=")
17 i := 0
18 for f, en := range fgs {
19 fmt.Fprintf(&strb, "%s=%v", string(f), en)
20 if i++; i != len(fgs) {
21 strb.WriteByte(',')
22 }
23 }
24 return strb.String()
25}
26
27// AsConfigObject returns the feature gates as a plain map for K8s configs.
28func (fgs featureGates) AsMap() map[string]bool {
29 out := make(map[string]bool)
30 for f, en := range fgs {
31 out[string(f)] = en
32 }
33 return out
34}
35
Lorenz Brun2ecccae2024-11-27 22:03:35 +010036var extraFeatureGates = featureGates{
37 features.UserNamespacesSupport: true,
38 features.UserNamespacesPodSecurityStandards: true,
39}