Skip to content

✨ helm chart directory can be configured #4891

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bavarianbidi
Copy link
Contributor

Per default, helm-charts will get generated under dist/ directory. Via the newly introduced --directory flag it's now possible to define an alternative directory (e.g.: chart)

fixes #4320

additional notes:
I've added a importas golangci rule for the helmv1alpha package as the import is handled in multiple files differently.
If this is fine, i will also raise another PR to add at least two new importas-rules for

	"sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/deploy-image/v1alpha1"
	"sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/grafana/v1alpha"

as it's super hard to read the code without having proper naming for equal sounded imports 😅

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 27, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bavarianbidi
Once this PR has been reviewed and has the lgtm label, please assign kavinjsir for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Hi @bavarianbidi. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 27, 2025
Comment on lines +31 to +33

// Directory is the directory where the Helm chart will be scaffolded
Directory string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also thought about adding a new machinery.HelmMixin which could be used for all helm-based structs, but decided to not do it for now as i wanted your feedback on this first.

@@ -66,6 +68,7 @@ manifests in the chart align with the latest changes.

func (p *editSubcommand) BindFlags(fs *pflag.FlagSet) {
fs.BoolVar(&p.force, "force", false, "if true, regenerates all the files")
fs.StringVar(&p.directory, "directory", HelmDefaultTargetDirectory, "domain for groups")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to as we do for the alpha generate.
I mean, use the name output-dir see

Currently, it supports two optional params, `input-dir` and `output-dir`.
`input-dir` is the path to the existing project that you want to re-scaffold. Default is the current working directory.
`output-dir` is the path to the directory where you want to generate the new project. Default is a subdirectory in the current working directory.

Consistency is the key :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output-dir as parameter-name for the helm-plugin will became an issue for alpha generate.
As output-dir is a parameter for alpha generate we can't identify if a user defined output-dir for the generate or the helm plugin.

I currently see the following options:

  • use output-dir as flag for the helm-plugin, and introduce an additional flag for alpha generate (e.g. --helm-output-dir where the value is getting propagated into the --output-dir of kubebuilder alpha generate --plugins=helm/v1-alpha --output-dir=<value>
  • use output-dir as flag for the helm-plugin and use the default-value of dist when kubebuilder alpha generate --plugins=helm/v1-alpha is getting called (user can still later do an kubebuilder edit --plugins=helm/v1-alpha --directory=<alternative dir> if they are not happy with the default>
  • introduce helm-output-dir as flag all over the place (alpha generate and edit --plugins=helm/v1-alpha)

with the argument of consistency, i would prefer the last one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bavarianbidi it should not be an issue for alpha generate because it will re-scaffold what is configured in the PROJECT file.
If we add this option to helm, the input will be in the config with the path used
We need supplement alpha generate for call the new flag with the plugin value, and all will work out.

@@ -13,6 +13,7 @@ linters:
- goconst
Copy link
Member

@camilamacedo86 camilamacedo86 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to add a test to ensure all helm plugin options are set.
I haven't thought of the best way yet.
However, I think we might want to add e2e tests , similar to the others https://github.com/kubernetes-sigs/kubebuilder/tree/master/test/e2e ,to mock scenarios with helm and verify that everything is as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding e2e:
do you mean, my introduced changes in the e2e-tests aren't sufficient?

do you want me to introduce a new e2e-test with a custom value for the helm output dir?
In the current impl. even the default-value will get persist in the PROJECT file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bavarianbidi

I thought about this one and IMO:

1 - We need to add the new flag to the alpha generate
2 - We need to add a new mock in alpha generation that includes the Helm plugin and will utilise this option. Then, at the end, we validate that the helm chart was output in the directory path provided. That should be enough to cover both scenarios in the scope of this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review how the alpha is generated and its associated tests. If you need a hand after that, please feel free to ping me in the Kubebuilder Slack channel. I am happy to help out.

@bavarianbidi
Copy link
Contributor Author

waiting for #4901

The helm-plugin is meant to extend an existing go project.
For a correct rendering of the helm-chart some information (like the project name) from the go project is
needed.

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
as helm init got removed, renamed
pkg/plugins/optional/helm/v1alpha/scaffolds/init.go ->
pkg/plugins/optional/helm/v1alpha/scaffolds/edit.go

also the NewInitHelmScaffolder func got renamed to NewHelmScaffolder

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
new minor cert-manager version will be used in testdata projects

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
Per default, helm-charts will get generated under dist/ directory.
Via the newly introduced --directory flag it's now possible to define an
alternative directory (e.g.: chart)

fixes kubernetes-sigs#4320

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
@bavarianbidi bavarianbidi force-pushed the allow_path_definition_for_helm_chart_generation branch from 4dc3596 to 83fa3dd Compare July 3, 2025 13:11
@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • 164e5ac feat: helm chart directory can be configured

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 3, 2025
@bavarianbidi bavarianbidi marked this pull request as draft July 3, 2025 13:12
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 3, 2025
@bavarianbidi
Copy link
Contributor Author

converted to Draft (for now) and rebased on top of #4903
will continue once #4903 get merged

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

target helm chart directory should be configurable
3 participants