@@ -161,20 +161,42 @@ func fetchKEPs() error {
161
161
return nil
162
162
}
163
163
164
- func filterKEPs (owningSig string , releases Releases ) (map [api.Stage ][]api.Proposal , error ) {
165
- kepsByStage := make (map [api.Stage ][]api.Proposal )
164
+ func stageIfKEPsIsWorkedInReleases (kepMilestone api.Milestone , releases Releases ) (api.Stage , bool ) {
165
+ if strings .HasSuffix (kepMilestone .Stable , releases .Latest ) || strings .HasSuffix (kepMilestone .Stable , releases .LatestMinusOne ) || strings .HasSuffix (kepMilestone .Stable , releases .LatestMinusTwo ) {
166
+ return api .StableStage , true
167
+ }
168
+
169
+ if strings .HasSuffix (kepMilestone .Beta , releases .Latest ) || strings .HasSuffix (kepMilestone .Beta , releases .LatestMinusOne ) || strings .HasSuffix (kepMilestone .Beta , releases .LatestMinusTwo ) {
170
+ return api .BetaStage , true
171
+ }
172
+
173
+ if strings .HasSuffix (kepMilestone .Alpha , releases .Latest ) || strings .HasSuffix (kepMilestone .Alpha , releases .LatestMinusOne ) || strings .HasSuffix (kepMilestone .Alpha , releases .LatestMinusTwo ) {
174
+ return api .AlphaStage , true
175
+ }
176
+
177
+ return "" , false
178
+ }
179
+
180
+ func filterKEPs (owningSig string , releases Releases ) (map [string ][]api.Proposal , error ) {
181
+ // TODO(palnabarun): Hack to allow unprefixed version strings in KEPs.
182
+ // Once all KEPs are updated to use the prefixed version strings, this can be removed.
183
+ // See: https://github.com/kubernetes/community/issues/7213#issuecomment-1484964640
184
+ unPrefixedReleases := Releases {
185
+ Latest : strings .TrimPrefix (releases .Latest , "v" ),
186
+ LatestMinusOne : strings .TrimPrefix (releases .LatestMinusOne , "v" ),
187
+ LatestMinusTwo : strings .TrimPrefix (releases .LatestMinusTwo , "v" ),
188
+ }
189
+
190
+ kepsByStage := make (map [string ][]api.Proposal )
166
191
for _ , kep := range cachedKEPs {
167
192
if kep .OwningSIG == owningSig {
168
- for _ , stage := range api .ValidStages {
169
- if kep .Stage == stage && (strings .HasSuffix (kep .LatestMilestone , releases .Latest ) ||
170
- strings .HasSuffix (kep .LatestMilestone , releases .LatestMinusOne ) ||
171
- strings .HasSuffix (kep .LatestMilestone , releases .LatestMinusTwo )) {
172
- kepsByStage [stage ] = append (kepsByStage [stage ], kep )
173
- }
193
+ stage , ok := stageIfKEPsIsWorkedInReleases (kep .Milestone , unPrefixedReleases )
194
+ if ! ok {
195
+ continue
174
196
}
197
+ kepsByStage [string (stage )] = append (kepsByStage [string (stage )], kep )
175
198
}
176
199
}
177
-
178
200
return kepsByStage , nil
179
201
}
180
202
0 commit comments