Skip to content

Commit 3ba25da

Browse files
committed
add chartName option to synth command when synth format is Helm
Signed-off-by: Matthew Cane <matthew.cane@citizensadvice.org.uk>
1 parent 3b5ebdd commit 3ba25da

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/cli/cmds/synth.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class Command implements yargs.CommandModule {
3232
.option('validation-reports-output-file', { required: false, desc: 'File to write a JSON representation of the validation reports to' })
3333
.option('format', { required: false, desc: 'Synthesis format for Kubernetes manifests. The default synthesis format is plain kubernetes manifests.', type: 'string' })
3434
.option('chart-api-version', { required: false, desc: 'Chart API version of helm chart. The default value would be \'v2\' api version when synthesis format is helm. There is no default set when synthesis format is plain.', type: 'string' })
35-
.option('chart-version', { required: false, desc: 'Chart version of helm chart. This is required if synthesis format is helm.' });
35+
.option('chart-version', { required: false, desc: 'Chart version of helm chart. This is required if synthesis format is helm.' })
36+
.option('chart-name', { required: false, desc: 'Chart name of helm chart. Use when synthesis format is helm. The default is the applications base directory name.' });
3637

3738
public async handler(argv: any) {
3839

@@ -45,6 +46,7 @@ class Command implements yargs.CommandModule {
4546
const format = argv.format ?? config?.synthConfig?.format ?? SynthesisFormat.PLAIN;
4647
const chartVersion = argv.chartVersion ?? config?.synthConfig?.chartVersion;
4748
const chartApiVersion = argv.chartApiVersion ?? config?.synthConfig?.chartApiVersion ?? getDefaultChartApiVersion(format);
49+
const chartName = argv.chartName ?? config?.synthConfig?.chartName ?? path.basename(path.resolve());
4850

4951
if (outdir && outdir !== config?.output && stdout) {
5052
throw new Error('\'--output\' and \'--stdout\' are mutually exclusive. Please only use one.');
@@ -104,7 +106,7 @@ class Command implements yargs.CommandModule {
104106
let manifests: SynthesizedApp;
105107

106108
if (format === SynthesisFormat.HELM) {
107-
await createHelmScaffolding(chartApiVersion, chartVersion, outdir);
109+
await createHelmScaffolding(chartApiVersion, chartVersion, chartName, outdir);
108110
const templateDir = path.join(outdir, 'templates');
109111

110112
manifests = await synthApp(command, templateDir, stdout, recordConstructMetadata);
@@ -130,13 +132,13 @@ async function fetchValidations(): Promise<ValidationConfig[] | undefined> {
130132
}
131133
}
132134

133-
async function createHelmScaffolding(apiVersion: string, chartVersion: string, outdir: string) {
135+
async function createHelmScaffolding(apiVersion: string, chartVersion: string, chartName: string, outdir: string) {
134136
const tempHelmStructure = createFolderStructure();
135137

136138
const substituteValues = {
137139
apiVersion: apiVersion,
138140
version: chartVersion,
139-
app: path.basename(path.resolve()),
141+
app: chartName,
140142
};
141143

142144
try {

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface SynthConfig {
3131
readonly format?: SynthesisFormat;
3232
readonly chartApiVersion?: HelmChartApiVersion;
3333
readonly chartVersion?: string;
34+
readonly chartName?: string;
3435
}
3536

3637
export interface Config {

0 commit comments

Comments
 (0)