@@ -209,8 +209,9 @@ func registerInSuite(ginkgoCall func(string, ...interface{}) bool, args []interf
209
209
case label :
210
210
fullLabel := strings .Join (arg .parts , ":" )
211
211
addLabel (fullLabel )
212
- if arg .extra != "" {
213
- addLabel (arg .extra )
212
+ if arg .extraFeature != "" {
213
+ texts = append (texts , fmt .Sprintf ("[%s]" , arg .extraFeature ))
214
+ ginkgoArgs = append (ginkgoArgs , ginkgo .Label ("Feature:" + arg .extraFeature ))
214
215
}
215
216
if fullLabel == "Serial" {
216
217
ginkgoArgs = append (ginkgoArgs , ginkgo .Serial )
@@ -309,6 +310,10 @@ func validateText(location types.CodeLocation, text string, labels []string) {
309
310
recordTextBug (location , fmt .Sprintf ("[%s] in plain text is deprecated and must be added through With%s instead" , tag , tag ))
310
311
}
311
312
if deprecatedStability .Has (tag ) {
313
+ if slices .Contains (labels , "Feature:" + tag ) {
314
+ // Okay, was also set as label.
315
+ continue
316
+ }
312
317
recordTextBug (location , fmt .Sprintf ("[%s] in plain text is deprecated and must be added by defining the feature gate through WithFeatureGate instead" , tag ))
313
318
}
314
319
if index := strings .Index (tag , ":" ); index > 0 {
@@ -353,6 +358,16 @@ func withFeature(name Feature) interface{} {
353
358
// [k8s.io/apiserver/pkg/util/feature.DefaultMutableFeatureGate]. Once a
354
359
// feature gate gets removed from there, the WithFeatureGate calls using it
355
360
// also need to be removed.
361
+ //
362
+ // [Alpha] resp. [Beta] get added to the test name automatically depending
363
+ // on the current stability level of the feature. Feature:Alpha resp.
364
+ // Feature:Beta get added to the Ginkgo labels because this is a special
365
+ // requirement for how the cluster needs to be configured.
366
+ //
367
+ // If the test can run in any cluster that has alpha resp. beta features and
368
+ // API groups enabled, then annotating it with just WithFeatureGate is
369
+ // sufficient. Otherwise, WithFeature has to be used to define the additional
370
+ // requirements.
356
371
func WithFeatureGate (featureGate featuregate.Feature ) interface {} {
357
372
return withFeatureGate (featureGate )
358
373
}
@@ -376,7 +391,7 @@ func withFeatureGate(featureGate featuregate.Feature) interface{} {
376
391
}
377
392
378
393
l := newLabel ("FeatureGate" , string (featureGate ))
379
- l .extra = level
394
+ l .extraFeature = level
380
395
return l
381
396
}
382
397
@@ -544,8 +559,9 @@ func withFlaky() interface{} {
544
559
type label struct {
545
560
// parts get concatenated with ":" to build the full label.
546
561
parts []string
547
- // extra is an optional fully-formed extra label.
548
- extra string
562
+ // extra is an optional feature name. It gets added as [<extraFeature>]
563
+ // to the test name and as Feature:<extraFeature> to the labels.
564
+ extraFeature string
549
565
// explanation gets set for each label to help developers
550
566
// who pass a label to a ginkgo function. They need to use
551
567
// the corresponding framework function instead.
@@ -572,7 +588,7 @@ func TagsEqual(a, b interface{}) bool {
572
588
if ! ok {
573
589
return false
574
590
}
575
- if al .extra != bl .extra {
591
+ if al .extraFeature != bl .extraFeature {
576
592
return false
577
593
}
578
594
return slices .Equal (al .parts , bl .parts )
0 commit comments