crd2pulumi
crd2pulumi copied to clipboard
[nodejs] Generated code is broken for grafana crd
What happened?
When running a grafana-operator crd the generated code is broken. I think the issue is the crd yaml is using dots which don't convert well to TS and should use instead a '_' char or something else that is supported in TS classes/interfaces names.
Steps to reproduce
download the crd file https://github.com/bitnami/charts/blob/master/bitnami/grafana-operator/crds/grafanas.integreatly.org.yaml
run:
crd2pulumi --nodejsPath grafanas grafanas.yaml
### Expected Behavior
the tool should generate code with no errors
### Actual Behavior
Generated code has a lot of errors such as:
Namespace 'grafanas/types/input".integreatly.v1alpha1' has no exported member 'XYZ'
### Versions used
I am using the latest crd2pulumi v1.2.0
### Additional context
_No response_
### Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
@mattolenik - could you take a look?
Hey @viveklak @mattolenik Are there any updates on this issue?
Ran into the issue as well while generating code for nodejs/typescript from the grafana-operator:
Sample output:
Invalid type names generated
export interface GrafanaSpecConfigExternal_image_storage.azure_blob {
account_key?: string;
account_name?: string;
container_name?: string;
}
Invalid property names generated:
/**
* GrafanaConfig is the configuration for grafana
*/
export interface GrafanaSpecConfig {
alerting?: outputs.integreatly.v1alpha1.GrafanaSpecConfigAlerting;
analytics?: outputs.integreatly.v1alpha1.GrafanaSpecConfigAnalytics;
auth?: outputs.integreatly.v1alpha1.GrafanaSpecConfigAuth;
auth.anonymous?: outputs.integreatly.v1alpha1.GrafanaSpecConfigAuthAnonymous;
auth.azuread?: outputs.integreatly.v1alpha1.GrafanaSpecConfigAuthAzuread;
// ...
}
I think the property names chosen by grafana-operator may not follow recommendations (i.e. kubernetes prefers using camel-case for yaml properties), but it still is valid yaml nonetheless.
I'd like to generalize the problem. crd2pulumi should ensure that properties and types generated from a CRD definiton are valid property and type names in the target language.
Added to epic https://github.com/pulumi/home/issues/3431
Dupe of #15