Skip to content

Commit bb023ca

Browse files
committed
🐛 envtest: CRDs that aren't convertible should unset spec.conversion
Signed-off-by: Vince Prignano <[email protected]>
1 parent c20ea14 commit bb023ca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/envtest/crd.go

Lines changed: 6 additions & 1 deletion
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)