kubernetes-sigs / kubebuilder

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

target helm chart directory should be configurable #4320

Open bavarianbidi opened 2 weeks ago

bavarianbidi commented 2 weeks ago

What do you want to happen?

I gave the very early helm.kubebuilder.io/v1-alpha plugin a try.

One downside with the generated manifests is the current chosen file path for the helm charts. All the content of the generated helm charts goes to ./dist folder on. (xref: relevant code places).

I very often use goreleaser for the release process. And per default, all the generated build artifacts will be placed under the ./dist folder. As these generated artifacts should not get tracked by git, we ignore the entire ./dist folder in our .gitignore file.

Per documentation, it's possible in goreleaser to change that location (xref: goreleaser doc). But as i do not prefer to change locations from an existing integrated tool, just because of integrating a new tool i would like to see to make the target folder configurable :pray:

I can take over the implementation if wanted

Extra Labels

No response

camilamacedo86 commented 2 weeks ago

Hi @bavarianbidi,

We use the dist directory to add the bundle done with YAML via Kustomize to allow people to distribute their solutions easily; see:

https://github.com/kubernetes-sigs/kubebuilder/blob/40db2b8c82d6846df0d4307f130a166ca2a8ce31/testdata/project-v4/Makefile#L129-L133

By default, this is the most logical place.

However, if you want to add an OPTIONAL flag to the plugin to allow people to output the chart elsewhere, please go forward with it. It seems like a nice improvement 🚀 .

The flag would need to be added at: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/optional/helm/v1alpha/init.go#L34-L42

And here: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/optional/helm/v1alpha/edit.go

Then, we need to track this info in the PROJECT file. See how we track all input provided when using the DeployImage plugin:

https://github.com/kubernetes-sigs/kubebuilder/blob/40db2b8c82d6846df0d4307f130a166ca2a8ce31/pkg/plugins/golang/deploy-image/v1alpha1/api.go#L193-L218

See how this results in the PROJECT file: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4-with-plugins/PROJECT#L8-L25

Then, we would also need to add a condition to retrieve this value when present for the command alpha generate:

https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/cli/alpha/internal/generate.go#L404-L411

Similar to what we do for the deploy image here: https://github.com/kubernetes-sigs/kubebuilder/blob/40db2b8c82d6846df0d4307f130a166ca2a8ce31/pkg/cli/alpha/internal/generate.go#L297-L313

Looking forward to see your PR 🥇