Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 envtest: CRDs that aren't convertible should unset spec.conversion #2525

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/envtest/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,16 @@ func modifyConversionWebhooks(crds []*apiextensionsv1.CustomResourceDefinition,
if crds[i].Spec.PreserveUnknownFields {
continue
}
// Continue if the GroupKind isn't registered as being convertible.
// Continue if the GroupKind isn't registered as being convertible,
// and remove any existing conversion webhooks if they exist.
// This is to prevent the CRD from being rejected by the apiserver, usually
// manifests that are generated by controller-gen will have a conversion
// webhook set, but we don't want to enable it if the type isn't registered.
if _, ok := convertibles[schema.GroupKind{
Group: crds[i].Spec.Group,
Kind: crds[i].Spec.Names.Kind,
}]; !ok {
crds[i].Spec.Conversion = nil
continue
}
if crds[i].Spec.Conversion == nil {
Expand Down