@@ -102,6 +102,9 @@ type Config struct {
102
102
// Name indicates the name of this webhook configuration. Should be a domain with at least three segments separated by dots
103
103
Name string
104
104
105
+ // K8sName indicates the K8s name of this webhook configuration.
106
+ K8sName string `marker:"k8sName,optional"`
107
+
105
108
// Path specifies that path that the API server should connect to this webhook on. Must be
106
109
// prefixed with a '/validate-' or '/mutate-' depending on the type, and followed by
107
110
// $GROUP-$VERSION-$KIND where all values are lower-cased and the periods in the group
@@ -370,6 +373,9 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
370
373
supportedWebhookVersions := supportedWebhookVersions ()
371
374
mutatingCfgs := make (map [string ][]admissionregv1.MutatingWebhook , len (supportedWebhookVersions ))
372
375
validatingCfgs := make (map [string ][]admissionregv1.ValidatingWebhook , len (supportedWebhookVersions ))
376
+ mutatingWebhookConfigurationK8sName := "mutating-webhook-configuration"
377
+ validatingWebhookConfigurationK8sName := "validating-webhook-configuration"
378
+
373
379
for _ , root := range ctx .Roots {
374
380
markerSet , err := markers .PackageMarkers (ctx .Collector , root )
375
381
if err != nil {
@@ -395,6 +401,9 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
395
401
for _ , webhookVersion := range webhookVersions {
396
402
mutatingCfgs [webhookVersion ] = append (mutatingCfgs [webhookVersion ], w )
397
403
}
404
+ if cfg .K8sName != "" {
405
+ mutatingWebhookConfigurationK8sName = cfg .K8sName
406
+ }
398
407
} else {
399
408
w , err := cfg .ToValidatingWebhook ()
400
409
if err != nil {
@@ -403,6 +412,9 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
403
412
for _ , webhookVersion := range webhookVersions {
404
413
validatingCfgs [webhookVersion ] = append (validatingCfgs [webhookVersion ], w )
405
414
}
415
+ if cfg .K8sName != "" {
416
+ validatingWebhookConfigurationK8sName = cfg .K8sName
417
+ }
406
418
}
407
419
}
408
420
}
@@ -418,7 +430,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
418
430
Version : version ,
419
431
Kind : "MutatingWebhookConfiguration" ,
420
432
})
421
- objRaw .SetName ("mutating-webhook-configuration" )
433
+ objRaw .SetName (mutatingWebhookConfigurationK8sName )
422
434
objRaw .Webhooks = cfgs
423
435
for i := range objRaw .Webhooks {
424
436
// SideEffects is required in admissionregistration/v1, if this is not set or set to `Some` or `Known`,
@@ -449,7 +461,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
449
461
Version : version ,
450
462
Kind : "ValidatingWebhookConfiguration" ,
451
463
})
452
- objRaw .SetName ("validating-webhook-configuration" )
464
+ objRaw .SetName (validatingWebhookConfigurationK8sName )
453
465
objRaw .Webhooks = cfgs
454
466
for i := range objRaw .Webhooks {
455
467
// SideEffects is required in admissionregistration/v1, if this is not set or set to `Some` or `Known`,
0 commit comments