Skip to content

Commit 2567468

Browse files
committed
Respect hyphens in helm chart names
From `json2jsii` 0.4.0 onwards, type name sanitization works correctly with kebab case, i.e. it no longer ignores hyphens, so that names like `ingress-nginx`, which previously have been previously converted to `Ingressnginx`, now get converted to `IngressNginx`, which is the expected behaviour for kebab case to camel case conversion. However, `cdk8s-cli`'s helm import has been additionally sanitizing hyphens in chart names, even though hyphens are valid characters in chart names, so that the change in `json2jsii` had no effect. This patch simplifies the helm importer's sanitization routine to not remove hyphens anymore, resulting in more correct class names. Signed-off-by: Nikolai Prokoschenko <[email protected]>
1 parent 2a685fd commit 2567468

File tree

2 files changed

+205
-205
lines changed

2 files changed

+205
-205
lines changed

src/import/codegen.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export interface HelmObjectDefinition {
256256
}
257257

258258
export function generateHelmConstruct(typegen: TypeGenerator, def: HelmObjectDefinition) {
259-
const noSpecialChars = def.chartName.replace(/([^\w ]|_)/g, '');
259+
const noSpecialChars = def.chartName.replace(/([^a-zA-Z0-9- ])/g, '');
260260
const chartName = TypeGenerator.normalizeTypeName(noSpecialChars);
261261
const schema = def.schema;
262262
const repoUrl = def.chartUrl;
@@ -421,4 +421,4 @@ export function generateHelmConstruct(typegen: TypeGenerator, def: HelmObjectDef
421421

422422
function hasRequiredProps(schema: JSONSchema4):boolean | undefined {
423423
return schema?.required && Array.isArray(schema.required) && schema.required.length > 0;
424-
}
424+
}

0 commit comments

Comments
 (0)