crd2pulumi icon indicating copy to clipboard operation
crd2pulumi copied to clipboard

[nodejs] Generated code is broken for grafana crd

Open roya opened this issue 2 years ago • 3 comments

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). 

roya avatar Jul 19 '22 06:07 roya

@mattolenik - could you take a look?

viveklak avatar Jul 20 '22 00:07 viveklak

Hey @viveklak @mattolenik Are there any updates on this issue?

roya avatar Aug 23 '22 13:08 roya

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.

jabbrwcky avatar Sep 14 '22 11:09 jabbrwcky

Added to epic https://github.com/pulumi/home/issues/3431

cleverguy25 avatar Aug 09 '24 23:08 cleverguy25

Dupe of #15

rquitales avatar Sep 13 '24 23:09 rquitales