Skip to content

Commit 5771399

Browse files
authored
Merge pull request #2525 from vincepri/webhook-crd-convertible-fix
🐛 envtest: CRDs that aren't convertible should unset spec.conversion
2 parents 2764d1d + bb023ca commit 5771399

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/envtest/crd.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,16 @@ func modifyConversionWebhooks(crds []*apiextensionsv1.CustomResourceDefinition,
371371
if crds[i].Spec.PreserveUnknownFields {
372372
continue
373373
}
374-
// Continue if the GroupKind isn't registered as being convertible.
374+
// Continue if the GroupKind isn't registered as being convertible,
375+
// and remove any existing conversion webhooks if they exist.
376+
// This is to prevent the CRD from being rejected by the apiserver, usually
377+
// manifests that are generated by controller-gen will have a conversion
378+
// webhook set, but we don't want to enable it if the type isn't registered.
375379
if _, ok := convertibles[schema.GroupKind{
376380
Group: crds[i].Spec.Group,
377381
Kind: crds[i].Spec.Names.Kind,
378382
}]; !ok {
383+
crds[i].Spec.Conversion = nil
379384
continue
380385
}
381386
if crds[i].Spec.Conversion == nil {

0 commit comments

Comments
 (0)