@@ -28,6 +28,11 @@ type FeatureGateDescription struct {
28
28
type FeatureGateEnabledDisabled struct {
29
29
Enabled []FeatureGateDescription
30
30
Disabled []FeatureGateDescription
31
+ // Map of component -> map of version -> description
32
+ // It would likely be better as map of component -> map of featureName -> version
33
+ // but let's revisit that.
34
+ // TODO FIXME
35
+ EnabledGivenMinimumVersion map [configv1.MinimumComponent ]map [string ][]configv1.FeatureGateAttributes
31
36
}
32
37
33
38
type ClusterProfileName string
@@ -46,11 +51,12 @@ var (
46
51
)
47
52
48
53
type featureGateBuilder struct {
49
- name string
50
- owningJiraComponent string
51
- responsiblePerson string
52
- owningProduct OwningProduct
53
- enhancementPRURL string
54
+ name string
55
+ owningJiraComponent string
56
+ responsiblePerson string
57
+ owningProduct OwningProduct
58
+ enhancementPRURL string
59
+ minimumKubeletVersion string
54
60
55
61
statusByClusterProfileByFeatureSet map [ClusterProfileName ]map [configv1.FeatureSet ]bool
56
62
}
@@ -111,6 +117,11 @@ func (b *featureGateBuilder) enableForClusterProfile(clusterProfile ClusterProfi
111
117
return b
112
118
}
113
119
120
+ func (b * featureGateBuilder ) enableInDefaultWhenRequiredMinimumComponentVersion (component configv1.MinimumComponent , version string ) * featureGateBuilder {
121
+ b .minimumKubeletVersion = version
122
+ return b
123
+ }
124
+
114
125
func (b * featureGateBuilder ) register () (configv1.FeatureGateName , error ) {
115
126
if len (b .name ) == 0 {
116
127
return "" , fmt .Errorf ("missing name" )
@@ -142,9 +153,20 @@ func (b *featureGateBuilder) register() (configv1.FeatureGateName, error) {
142
153
}
143
154
144
155
featureGateName := configv1 .FeatureGateName (b .name )
156
+ var minComponentVersions []configv1.MinimumComponentVersion
157
+ if b .minimumKubeletVersion != "" {
158
+ if minComponentVersions == nil {
159
+ minComponentVersions = []configv1.MinimumComponentVersion {}
160
+ }
161
+ minComponentVersions = append (minComponentVersions , configv1.MinimumComponentVersion {
162
+ Component : configv1 .MinimumComponentKubelet ,
163
+ Version : b .minimumKubeletVersion ,
164
+ })
165
+ }
145
166
description := FeatureGateDescription {
146
167
FeatureGateAttributes : configv1.FeatureGateAttributes {
147
- Name : featureGateName ,
168
+ Name : featureGateName ,
169
+ RequiredMinimumComponentVersions : minComponentVersions ,
148
170
},
149
171
OwningJiraComponent : b .owningJiraComponent ,
150
172
ResponsiblePerson : b .responsiblePerson ,
@@ -167,6 +189,20 @@ func (b *featureGateBuilder) register() (configv1.FeatureGateName, error) {
167
189
} else {
168
190
allFeatureGates [clusterProfile ][featureSet ].Disabled = append (allFeatureGates [clusterProfile ][featureSet ].Disabled , description )
169
191
}
192
+ if b .minimumKubeletVersion != "" {
193
+ if allFeatureGates [clusterProfile ][featureSet ].EnabledGivenMinimumVersion == nil {
194
+ allFeatureGates [clusterProfile ][featureSet ].EnabledGivenMinimumVersion = map [configv1.MinimumComponent ]map [string ][]configv1.FeatureGateAttributes {}
195
+ }
196
+ if _ , ok := allFeatureGates [clusterProfile ][featureSet ].EnabledGivenMinimumVersion [configv1 .MinimumComponentKubelet ]; ! ok {
197
+ allFeatureGates [clusterProfile ][featureSet ].EnabledGivenMinimumVersion [configv1 .MinimumComponentKubelet ] = map [string ][]configv1.FeatureGateAttributes {}
198
+ }
199
+ features , ok := allFeatureGates [clusterProfile ][featureSet ].EnabledGivenMinimumVersion [configv1 .MinimumComponentKubelet ][b .minimumKubeletVersion ]
200
+ if ! ok {
201
+ features = []configv1.FeatureGateAttributes {}
202
+ }
203
+ // TODO FIXME: This is hellish, is there a better way?
204
+ allFeatureGates [clusterProfile ][featureSet ].EnabledGivenMinimumVersion [configv1 .MinimumComponentKubelet ][b .minimumKubeletVersion ] = append (features , description .FeatureGateAttributes )
205
+ }
170
206
}
171
207
}
172
208
0 commit comments