| Lorenz Brun | d58edf4 | 2024-11-27 20:38:14 +0000 | [diff] [blame] | 1 | package kubernetes |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | |
| 7 | "k8s.io/component-base/featuregate" |
| Lorenz Brun | 2ecccae | 2024-11-27 22:03:35 +0100 | [diff] [blame^] | 8 | "k8s.io/kubernetes/pkg/features" |
| Lorenz Brun | d58edf4 | 2024-11-27 20:38:14 +0000 | [diff] [blame] | 9 | ) |
| 10 | |
| 11 | type featureGates map[featuregate.Feature]bool |
| 12 | |
| 13 | // AsFlag returns the feature gates as a --feature-gate flag. |
| 14 | func (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. |
| 28 | func (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 Brun | 2ecccae | 2024-11-27 22:03:35 +0100 | [diff] [blame^] | 36 | var extraFeatureGates = featureGates{ |
| 37 | features.UserNamespacesSupport: true, |
| 38 | features.UserNamespacesPodSecurityStandards: true, |
| 39 | } |