diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/kustomization.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/kustomization.yaml index 70b68e0b2d4..ce4e7415d87 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/kustomization.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/kustomization.yaml @@ -8,16 +8,13 @@ resources: patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -- path: patches/webhook_in_cronjobs.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -- path: patches/cainjection_in_cronjobs.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - -configurations: -- kustomizeconfig.yaml +#configurations: +#- kustomizeconfig.yaml diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml deleted file mode 100644 index 752fa9ac6a0..00000000000 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: cronjobs.batch.tutorial.kubebuilder.io diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/webhook_in_cronjobs.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/webhook_in_cronjobs.yaml deleted file mode 100644 index 3e96e59513a..00000000000 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/webhook_in_cronjobs.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: cronjobs.batch.tutorial.kubebuilder.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml b/docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml index 687b9e370cc..2cb67e5e885 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml @@ -14,16 +14,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: cronjobs.batch.tutorial.kubebuilder.io spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-webhook-service - namespace: project-system - path: /convert - conversionReviewVersions: - - v1 group: batch.tutorial.kubebuilder.io names: kind: CronJob diff --git a/docs/book/src/getting-started/testdata/project/config/crd/kustomization.yaml b/docs/book/src/getting-started/testdata/project/config/crd/kustomization.yaml index b43703d1585..217b2175494 100644 --- a/docs/book/src/getting-started/testdata/project/config/crd/kustomization.yaml +++ b/docs/book/src/getting-started/testdata/project/config/crd/kustomization.yaml @@ -12,11 +12,9 @@ patches: # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_memcacheds.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - #configurations: #- kustomizeconfig.yaml diff --git a/docs/book/src/multiversion-tutorial/testdata/project/config/crd/kustomization.yaml b/docs/book/src/multiversion-tutorial/testdata/project/config/crd/kustomization.yaml index fe5ceed15a8..4cae15b8d87 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/config/crd/kustomization.yaml +++ b/docs/book/src/multiversion-tutorial/testdata/project/config/crd/kustomization.yaml @@ -9,17 +9,14 @@ patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD - path: patches/webhook_in_cronjobs.yaml -- path: patches/webhook_in_cronjobs.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -- path: patches/cainjection_in_cronjobs.yaml #- path: patches/cainjection_in_cronjobs.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - configurations: - kustomizeconfig.yaml diff --git a/hack/docs/internal/cronjob-tutorial/generate_cronjob.go b/hack/docs/internal/cronjob-tutorial/generate_cronjob.go index 793b43dc3b1..e447b5efff5 100644 --- a/hack/docs/internal/cronjob-tutorial/generate_cronjob.go +++ b/hack/docs/internal/cronjob-tutorial/generate_cronjob.go @@ -595,11 +595,6 @@ func (sp *Sample) updateKustomization() { filepath.Join(sp.ctx.Dir, "config/default/kustomization.yaml"), certmanagerForWebhooks, `#`) hackutils.CheckError("fixing default/kustomization", err) - - err = pluginutil.UncommentCode( - filepath.Join(sp.ctx.Dir, "config/crd/kustomization.yaml"), - `#- path: patches/cainjection_in_cronjobs.yaml`, `#`) - hackutils.CheckError("fixing crd/kustomization", err) } func (sp *Sample) updateExample() { diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go index 2da3a06a8cb..fe982d7b8af 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go @@ -70,7 +70,7 @@ func (f *Kustomization) GetMarkers() []machinery.Marker { const ( resourceCodeFragment = `- bases/%s_%s.yaml ` - webhookPatchCodeFragment = `#- path: patches/webhook_in_%s.yaml + webhookPatchCodeFragment = `- path: patches/webhook_in_%s.yaml ` caInjectionPatchCodeFragment = `#- path: patches/cainjection_in_%s.yaml ` @@ -89,7 +89,7 @@ func (f *Kustomization) GetCodeFragments() machinery.CodeFragmentsMap { suffix = f.Resource.Group + "_" + f.Resource.Plural } - if !f.Resource.Webhooks.IsEmpty() { + if !f.Resource.Webhooks.IsEmpty() && f.Resource.Webhooks.Conversion { webhookPatch := fmt.Sprintf(webhookPatchCodeFragment, suffix) marker := machinery.NewMarkerFor(f.Path, webhookPatchMarker) @@ -100,7 +100,9 @@ func (f *Kustomization) GetCodeFragments() machinery.CodeFragmentsMap { // Generate resource code fragments caInjectionPatch := make([]string, 0) - caInjectionPatch = append(caInjectionPatch, fmt.Sprintf(caInjectionPatchCodeFragment, suffix)) + if !f.Resource.Webhooks.IsEmpty() && f.Resource.Webhooks.Conversion { + caInjectionPatch = append(caInjectionPatch, fmt.Sprintf(caInjectionPatchCodeFragment, suffix)) + } // Only store code fragments in the map if the slices are non-empty if len(res) != 0 { @@ -131,7 +133,6 @@ patches: # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - #configurations: #- kustomizeconfig.yaml ` diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/webhook.go b/pkg/plugins/common/kustomize/v2/scaffolds/webhook.go index d919b3088e1..fd871ecffef 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/webhook.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/webhook.go @@ -19,16 +19,16 @@ package scaffolds import ( "fmt" - log "github.com/sirupsen/logrus" - pluginutil "sigs.k8s.io/kubebuilder/v4/pkg/plugin/util" - "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches" + log "github.com/sirupsen/logrus" "sigs.k8s.io/kubebuilder/v4/pkg/config" "sigs.k8s.io/kubebuilder/v4/pkg/machinery" "sigs.k8s.io/kubebuilder/v4/pkg/model/resource" + pluginutil "sigs.k8s.io/kubebuilder/v4/pkg/plugin/util" "sigs.k8s.io/kubebuilder/v4/pkg/plugins" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager" + "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault" network_policy "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook" @@ -81,11 +81,15 @@ func (s *webhookScaffolder) Scaffold() error { &certmanager.Certificate{}, &certmanager.Kustomization{}, &certmanager.KustomizeConfig{}, - &patches.EnableWebhookPatch{}, - &patches.EnableCAInjectionPatch{}, &network_policy.NetworkPolicyAllowWebhooks{}, } + // Only scaffold the following patches if is a conversion webhook + if s.resource.Webhooks.Conversion { + buildScaffold = append(buildScaffold, &patches.EnableWebhookPatch{}) + buildScaffold = append(buildScaffold, &patches.EnableCAInjectionPatch{}) + } + if !s.resource.External && !s.resource.Core { buildScaffold = append(buildScaffold, &crd.Kustomization{}) } @@ -130,22 +134,17 @@ func (s *webhookScaffolder) Scaffold() error { } } - crdKustomizationsFilePath := "config/crd/kustomization.yaml" - err = pluginutil.UncommentCode(crdKustomizationsFilePath, "#- path: patches/webhook", `#`) - if err != nil { - hasWebHookUncommented, err := pluginutil.HasFileContentWith(crdKustomizationsFilePath, "- path: patches/webhook") - if !hasWebHookUncommented || err != nil { - log.Errorf("Unable to find the target(s) #- path: patches/webhook/* to uncomment in the file "+ - "%s.", crdKustomizationsFilePath) - } - } - - err = pluginutil.UncommentCode(crdKustomizationsFilePath, "#configurations:\n#- kustomizeconfig.yaml", `#`) - if err != nil { - hasWebHookUncommented, err := pluginutil.HasFileContentWith(crdKustomizationsFilePath, "- kustomizeconfig.yaml") - if !hasWebHookUncommented || err != nil { - log.Errorf("Unable to find the target(s) #configurations:\n#- kustomizeconfig.yaml to uncomment in the file "+ - "%s.", crdKustomizationsFilePath) + if s.resource.Webhooks.Conversion { + crdKustomizationsFilePath := "config/crd/kustomization.yaml" + err = pluginutil.UncommentCode(crdKustomizationsFilePath, "#configurations:\n#- kustomizeconfig.yaml", `#`) + if err != nil { + hasWebHookUncommented, err := pluginutil.HasFileContentWith(crdKustomizationsFilePath, + "configurations:\n- kustomizeconfig.yaml") + if !hasWebHookUncommented || err != nil { + log.Warningf("Unable to find the target(s) configurations.kustomizeconfig.yaml "+ + "to uncomment in the file "+ + "%s.", crdKustomizationsFilePath) + } } } diff --git a/testdata/project-v4-multigroup/config/crd/kustomization.yaml b/testdata/project-v4-multigroup/config/crd/kustomization.yaml index 193cb75cbfb..5797248847e 100644 --- a/testdata/project-v4-multigroup/config/crd/kustomization.yaml +++ b/testdata/project-v4-multigroup/config/crd/kustomization.yaml @@ -19,31 +19,15 @@ resources: patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -- path: patches/webhook_in_crew_captains.yaml -- path: patches/webhook_in_ship_destroyers.yaml -- path: patches/webhook_in_ship_cruisers.yaml -- path: patches/webhook_in_example.com_memcacheds.yaml - path: patches/webhook_in_example.com_wordpresses.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_crew_captains.yaml -#- path: patches/cainjection_in_ship_frigates.yaml -#- path: patches/cainjection_in_ship_destroyers.yaml -#- path: patches/cainjection_in_ship_cruisers.yaml -#- path: patches/cainjection_in_sea-creatures_krakens.yaml -#- path: patches/cainjection_in_sea-creatures_leviathans.yaml -#- path: patches/cainjection_in_foo.policy_healthcheckpolicies.yaml -#- path: patches/cainjection_in_foo_bars.yaml -#- path: patches/cainjection_in_fiz_bars.yaml -#- path: patches/cainjection_in_example.com_memcacheds.yaml -#- path: patches/cainjection_in_example.com_busyboxes.yaml #- path: patches/cainjection_in_example.com_wordpresses.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - configurations: - kustomizeconfig.yaml diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_cert-manager_issuers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_cert-manager_issuers.yaml deleted file mode 100644 index c23d48081df..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_cert-manager_issuers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: issuers.cert-manager.io diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_core_pods.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_core_pods.yaml deleted file mode 100644 index b1ab830f8f6..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_core_pods.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: pods.core diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_crew_captains.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_crew_captains.yaml deleted file mode 100644 index fba0c3ed6fd..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_crew_captains.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: captains.crew.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_example.com_memcacheds.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_example.com_memcacheds.yaml deleted file mode 100644 index 5b9e839364d..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_example.com_memcacheds.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: memcacheds.example.com.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_cruisers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_cruisers.yaml deleted file mode 100644 index 0d31cb0b8af..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_cruisers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: cruisers.ship.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_destroyers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_destroyers.yaml deleted file mode 100644 index 865395574ff..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_destroyers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: destroyers.ship.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_cert-manager_issuers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_cert-manager_issuers.yaml deleted file mode 100644 index 29988f44a9b..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_cert-manager_issuers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: issuers.cert-manager.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_core_pods.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_core_pods.yaml deleted file mode 100644 index 8fa5d252208..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_core_pods.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: pods.core -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_crew_captains.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_crew_captains.yaml deleted file mode 100644 index f73ae2e8abc..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_crew_captains.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: captains.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_example.com_memcacheds.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_example.com_memcacheds.yaml deleted file mode 100644 index 4a56b0f4c69..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_example.com_memcacheds.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: memcacheds.example.com.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_cruisers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_cruisers.yaml deleted file mode 100644 index 99b6b6741b6..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_cruisers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: cruisers.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_destroyers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_destroyers.yaml deleted file mode 100644 index 0e0095cb3a6..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_destroyers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: destroyers.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/dist/install.yaml b/testdata/project-v4-multigroup/dist/install.yaml index 44294bdc330..1f7b09ab3c3 100644 --- a/testdata/project-v4-multigroup/dist/install.yaml +++ b/testdata/project-v4-multigroup/dist/install.yaml @@ -238,16 +238,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: captains.crew.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 group: crew.testproject.org names: kind: Captain @@ -302,16 +292,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: cruisers.ship.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 group: ship.testproject.org names: kind: Cruiser @@ -366,16 +346,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: destroyers.ship.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 group: ship.testproject.org names: kind: Destroyer @@ -646,16 +616,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: memcacheds.example.com.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 group: example.com.testproject.org names: kind: Memcached diff --git a/testdata/project-v4-with-plugins/config/crd/kustomization.yaml b/testdata/project-v4-with-plugins/config/crd/kustomization.yaml index d00fe0769fc..f33d8f1c5b2 100644 --- a/testdata/project-v4-with-plugins/config/crd/kustomization.yaml +++ b/testdata/project-v4-with-plugins/config/crd/kustomization.yaml @@ -10,19 +10,15 @@ resources: patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -- path: patches/webhook_in_memcacheds.yaml - path: patches/webhook_in_wordpresses.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_memcacheds.yaml -#- path: patches/cainjection_in_busyboxes.yaml #- path: patches/cainjection_in_wordpresses.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - configurations: - kustomizeconfig.yaml diff --git a/testdata/project-v4-with-plugins/config/crd/patches/cainjection_in_memcacheds.yaml b/testdata/project-v4-with-plugins/config/crd/patches/cainjection_in_memcacheds.yaml deleted file mode 100644 index 5b9e839364d..00000000000 --- a/testdata/project-v4-with-plugins/config/crd/patches/cainjection_in_memcacheds.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: memcacheds.example.com.testproject.org diff --git a/testdata/project-v4-with-plugins/config/crd/patches/webhook_in_memcacheds.yaml b/testdata/project-v4-with-plugins/config/crd/patches/webhook_in_memcacheds.yaml deleted file mode 100644 index 4a56b0f4c69..00000000000 --- a/testdata/project-v4-with-plugins/config/crd/patches/webhook_in_memcacheds.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: memcacheds.example.com.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-with-plugins/dist/install.yaml b/testdata/project-v4-with-plugins/dist/install.yaml index 875bfef3a06..8dbf5ac23bf 100644 --- a/testdata/project-v4-with-plugins/dist/install.yaml +++ b/testdata/project-v4-with-plugins/dist/install.yaml @@ -130,16 +130,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: memcacheds.example.com.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-with-plugins-webhook-service - namespace: project-v4-with-plugins-system - path: /convert - conversionReviewVersions: - - v1 group: example.com.testproject.org names: kind: Memcached diff --git a/testdata/project-v4/config/crd/kustomization.yaml b/testdata/project-v4/config/crd/kustomization.yaml index 614a75ff244..ee1e6daefc4 100644 --- a/testdata/project-v4/config/crd/kustomization.yaml +++ b/testdata/project-v4/config/crd/kustomization.yaml @@ -10,20 +10,15 @@ resources: patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -- path: patches/webhook_in_captains.yaml - path: patches/webhook_in_firstmates.yaml -- path: patches/webhook_in_admirales.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_captains.yaml #- path: patches/cainjection_in_firstmates.yaml -#- path: patches/cainjection_in_admirales.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section # the following config is for teaching kustomize how to do kustomization for CRDs. - configurations: - kustomizeconfig.yaml diff --git a/testdata/project-v4/config/crd/patches/cainjection_in_admirales.yaml b/testdata/project-v4/config/crd/patches/cainjection_in_admirales.yaml deleted file mode 100644 index 62b3a694a37..00000000000 --- a/testdata/project-v4/config/crd/patches/cainjection_in_admirales.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: admirales.crew.testproject.org diff --git a/testdata/project-v4/config/crd/patches/cainjection_in_captains.yaml b/testdata/project-v4/config/crd/patches/cainjection_in_captains.yaml deleted file mode 100644 index fba0c3ed6fd..00000000000 --- a/testdata/project-v4/config/crd/patches/cainjection_in_captains.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: captains.crew.testproject.org diff --git a/testdata/project-v4/config/crd/patches/cainjection_in_issuers.yaml b/testdata/project-v4/config/crd/patches/cainjection_in_issuers.yaml deleted file mode 100644 index c23d48081df..00000000000 --- a/testdata/project-v4/config/crd/patches/cainjection_in_issuers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: issuers.cert-manager.io diff --git a/testdata/project-v4/config/crd/patches/cainjection_in_pods.yaml b/testdata/project-v4/config/crd/patches/cainjection_in_pods.yaml deleted file mode 100644 index b1ab830f8f6..00000000000 --- a/testdata/project-v4/config/crd/patches/cainjection_in_pods.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: pods.core diff --git a/testdata/project-v4/config/crd/patches/webhook_in_admirales.yaml b/testdata/project-v4/config/crd/patches/webhook_in_admirales.yaml deleted file mode 100644 index cf986a6a411..00000000000 --- a/testdata/project-v4/config/crd/patches/webhook_in_admirales.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: admirales.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4/config/crd/patches/webhook_in_captains.yaml b/testdata/project-v4/config/crd/patches/webhook_in_captains.yaml deleted file mode 100644 index f73ae2e8abc..00000000000 --- a/testdata/project-v4/config/crd/patches/webhook_in_captains.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: captains.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4/config/crd/patches/webhook_in_issuers.yaml b/testdata/project-v4/config/crd/patches/webhook_in_issuers.yaml deleted file mode 100644 index 29988f44a9b..00000000000 --- a/testdata/project-v4/config/crd/patches/webhook_in_issuers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: issuers.cert-manager.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4/config/crd/patches/webhook_in_pods.yaml b/testdata/project-v4/config/crd/patches/webhook_in_pods.yaml deleted file mode 100644 index 8fa5d252208..00000000000 --- a/testdata/project-v4/config/crd/patches/webhook_in_pods.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: pods.core -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4/dist/install.yaml b/testdata/project-v4/dist/install.yaml index 5290b3bd872..9b1821f4e6b 100644 --- a/testdata/project-v4/dist/install.yaml +++ b/testdata/project-v4/dist/install.yaml @@ -14,16 +14,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: admirales.crew.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-webhook-service - namespace: project-v4-system - path: /convert - conversionReviewVersions: - - v1 group: crew.testproject.org names: kind: Admiral @@ -78,16 +68,6 @@ metadata: controller-gen.kubebuilder.io/version: v0.16.4 name: captains.crew.testproject.org spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-webhook-service - namespace: project-v4-system - path: /convert - conversionReviewVersions: - - v1 group: crew.testproject.org names: kind: Captain