Skip to content

Commit

Permalink
Respect hyphens in helm chart names
Browse files Browse the repository at this point in the history
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 pascal 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]>
  • Loading branch information
rassie committed Nov 21, 2023
1 parent 2a685fd commit 6f782a4
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 205 deletions.
4 changes: 2 additions & 2 deletions src/import/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export interface HelmObjectDefinition {
}

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

function hasRequiredProps(schema: JSONSchema4):boolean | undefined {
return schema?.required && Array.isArray(schema.required) && schema.required.length > 0;
}
}
Loading

0 comments on commit 6f782a4

Please sign in to comment.