Skip to content

Commit

Permalink
Merge pull request #2525 from vincepri/webhook-crd-convertible-fix
Browse files Browse the repository at this point in the history
🐛 envtest: CRDs that aren't convertible should unset spec.conversion
  • Loading branch information
k8s-ci-robot authored Oct 5, 2023
2 parents 2764d1d + bb023ca commit 5771399
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 5771399

Please sign in to comment.