Skip to content

feat(synth): option to specify chart name for helm format #3458

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

Open
wants to merge 5 commits into
base: 2.x
Choose a base branch
from

Conversation

MatthewCane
Copy link

@MatthewCane MatthewCane commented Jun 9, 2025

Currently, when synthesising an app as a Helm chart the chart name is the base path of the chart.

This presents an issue when a cdk8s application is not in the root of the project, for example if the application is located in /infrastructure/chart within a larger project, the name of the chart will just be chart. This could be confusing.

This change adds an optional parameter --chart-name in the CLI or chartName in the config file that will allow users to override this value.

I have added tests which pass and tested locally and it works as expected.

This is my first PR for cdk8s so I am open to suggestions for improvements.

@MatthewCane MatthewCane changed the title feat: add chartName option to synth command when synth format is Helm feat: Add --chart-name option to synth command when synth format is Helm Jun 9, 2025
auto-merge was automatically disabled June 9, 2025 16:16

Head branch was pushed to by a user without write access

@MatthewCane MatthewCane force-pushed the allow-custom-chart-name branch 3 times, most recently from 217ff0f to 3ba25da Compare June 9, 2025 16:18
@MatthewCane
Copy link
Author

@iliapolo could I get some feedback on this please? Thanks!

@iliapolo iliapolo changed the title feat: Add --chart-name option to synth command when synth format is Helm feat(synth): --chart-name option to format is helm Jun 30, 2025
@iliapolo iliapolo changed the title feat(synth): --chart-name option to format is helm feat(synth): option to specify chart name for helm format Jun 30, 2025
Copy link
Member

@iliapolo iliapolo left a comment

Choose a reason for hiding this comment

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

Nice! Just one small fix to the test.

exports[`Helm synthesis --chart-name is used when specified with all inputs from cli and no config file is present 1`] = `
Object {
"Chart.yaml": "apiVersion: \\"v2\\"
name: \\"cdk8s-synth-test\\"
Copy link
Member

Choose a reason for hiding this comment

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

I believe this isn't the expected value here - it should be custom-chart-name?

Its because you need to add chartName here:

chartVersion: options.chartVersion,

Otherwise, the cli input tests don't actually pass it to the synth handler.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, thank you for the feedback! I have added that now and pushed the change.

@iliapolo iliapolo added the response-requested Awaiting response from author label Jun 30, 2025
@MatthewCane MatthewCane requested a review from iliapolo July 2, 2025 11:12
synthConfig: {
format: SynthesisFormat.HELM,
chartVersion: '1.1.1',
chartName: 'custom-chart-name',
Copy link
Member

Choose a reason for hiding this comment

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

Dont think this belongs here - this test says its checking for: "default chart name is used when --chart-name is not specified %s".

So why add it?

Note that my previous comment was about adding chartName here:

chartVersion: options.chartVersion,

So:

      chartApiVersion: options.chartApiVersion,
      chartVersion: options.chartVersion,
+    chartName: options.chartName

Copy link
Author

Choose a reason for hiding this comment

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

It's been a while since I could look at this, does it look better now?

Signed-off-by: Matthew Cane <matthew.cane@citizensadvice.org.uk>
Signed-off-by: Matthew Cane <matthew.cane@citizensadvice.org.uk>
@MatthewCane MatthewCane force-pushed the allow-custom-chart-name branch from 259ae18 to c675990 Compare July 2, 2025 14:42
Signed-off-by: Matthew Cane <matthew.cane@citizensadvice.org.uk>
@MatthewCane MatthewCane force-pushed the allow-custom-chart-name branch from c675990 to b7e8210 Compare July 2, 2025 14:49
Copy link
Contributor

This PR has not received a response in a while and will be closed soon. If you want to keep it open, please leave a comment below @mentioning a maintainer.

@github-actions github-actions bot added the closing-soon Issue/PR will be closing soon if no response is provided label Jul 11, 2025
@MatthewCane MatthewCane force-pushed the allow-custom-chart-name branch from a33536a to f9fdd40 Compare July 15, 2025 09:03
@MatthewCane MatthewCane requested a review from iliapolo July 15, 2025 09:04
@MatthewCane
Copy link
Author

@iliapolo I have pushed an update, sorry for the delay, I've not been able to look at this for a while.

@github-actions github-actions bot removed closing-soon Issue/PR will be closing soon if no response is provided response-requested Awaiting response from author labels Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants