kubernetes-sigs / kubebuilder

Kubebuilder - SDK for building Kubernetes APIs using CRDs
http://book.kubebuilder.io
Apache License 2.0
7.89k stars 1.45k forks source link

Duplicate Webhook Patch Entries in config/crd/kustomization.yaml When Creating Multiple Versions of the Same Kind #4143

Closed camilamacedo86 closed 3 weeks ago

camilamacedo86 commented 2 months ago

What broke? What's expected?

When creating multiple versions for the same kind, in the config/crd/kustomization.yaml, there are duplicate entries for the webhook patch path:

- path: patches/webhook_in_cronjobs.yaml
- path: patches/webhook_in_cronjobs.yaml
- path: patches/webhook_in_cronjobs.yaml
- path: patches/webhook_in_cronjobs.yaml

The config/crd/kustomization.yaml file should contain only one entry for the webhook patch, regardless of the number of versions for the same kind. The path should only be added if it is not already present.

The implementation to add the value with the marker is here:

https://github.com/kubernetes-sigs/kubebuilder/blob/e3ebfafde3b7ac81588ee7c30c93b75494334dec/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go#L92-L95

Reproducing this issue

kubebuilder init
kubebuilder create api --group batch --version v1 --kind CronJob
kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation --conversion
kubebuilder create api --group batch --version v2 --kind CronJob
kubebuilder create webhook --group batch --version v2 --kind CronJob --defaulting --programmatic-validation --conversion

KubeBuilder (CLI) Version

master

PROJECT version

No response

Plugin versions

go/v4

Other versions

No response

Extra Labels

No response

TAM360 commented 1 month ago

/assign

ansh-devs commented 1 month ago

Hi @TAM360, are you still resolving this ?

TAM360 commented 1 month ago

@ansh-devs yup, working on it.

Bharadwajshivam28 commented 3 weeks ago

/assign