Helm import generates invalid TypeScript for property names with forward slashes
Description
When importing a Helm chart that contains JSON Schema property names with forward slashes, cdk8s generates invalid TypeScript code.
Steps to Reproduce
- Import the Grafana k8s-monitoring Helm chart:
cdk8s import helm:https://grafana.github.io/helm-charts/k8s-monitoring@3.5.6
- Generated TypeScript file
imports/k8s-monitoring.ts has syntax errors on lines 1335, 1345, 1359, and 1369
Expected Behavior
Property names containing forward slashes should be sanitized to valid TypeScript identifiers (e.g., kubernetesIoOs) or accessed via bracket notation.
Actual Behavior
The code generator converts JSON schema property names like "kubernetes.io/os" to camelCase identifiers that still contain forward slashes, resulting in invalid TypeScript:
Line 1335:
readonly kubernetesIo/os?: string; // Invalid syntax - `/` in property name
Line 1345:
'kubernetes.io/os': obj.kubernetesIo/os, // Invalid - `/` treated as division operator
Line 1359:
readonly k8SGrafanaCom/logsJob?: string; // Invalid syntax - `/` in property name
Line 1369:
'k8s.grafana.com/logs.job': obj.k8SGrafanaCom/logsJob, // Invalid - `/` treated as division operator
Environment
- cdk8s version: 2.203.1
- Helm chart:
https://grafana.github.io/helm-charts/k8s-monitoring@3.5.6
- Node version: v22.17.0
- Operating System: macOS
Currently working around by manually editing the resulting typescript
Helm import generates invalid TypeScript for property names with forward slashes
Description
When importing a Helm chart that contains JSON Schema property names with forward slashes, cdk8s generates invalid TypeScript code.
Steps to Reproduce
imports/k8s-monitoring.tshas syntax errors on lines 1335, 1345, 1359, and 1369Expected Behavior
Property names containing forward slashes should be sanitized to valid TypeScript identifiers (e.g.,
kubernetesIoOs) or accessed via bracket notation.Actual Behavior
The code generator converts JSON schema property names like
"kubernetes.io/os"to camelCase identifiers that still contain forward slashes, resulting in invalid TypeScript:Line 1335:
Line 1345:
Line 1359:
Line 1369:
Environment
https://grafana.github.io/helm-charts/k8s-monitoring@3.5.6Currently working around by manually editing the resulting typescript