crd2pulumi icon indicating copy to clipboard operation
crd2pulumi copied to clipboard

Invalid typescript code produced when generating for strimzi crds

Open maxemann96 opened this issue 2 years ago • 5 comments

What happened?

The following invalid typescript code is produced (Stripped the other invalid generated code as the error is always the same).

export interface KafkaConnectSpecJvmoptions {
      /**
       * A map of -XX options to the JVM.
       */
      -XX?: { [key: string]: any };
      /**
       * -Xms option to to the JVM.
       */
      -Xms?: string;
      /**
       * -Xmx option to to the JVM.
       */
      -Xmx?: string;
      /**
       * Specifies whether the Garbage Collection logging is enabled. The default is false.
       */
      gcLoggingEnabled?: boolean;
      /**
       * A map of additional system properties which will be passed using the `-D` option to the JVM.
       */
      javaSystemProperties?: outputs.kafka.v1beta2.KafkaConnectSpecJvmoptionsJavasystemproperties[];
    }

Steps to reproduce

Get the strimzi crds and generate the typescript code for example with crd2pulumi --nodejs --nodejsPath=crds/nodejs/ crds/k8s/*.yaml. The following excerpt automatically downloads the crds:

mkdir -p crds/k8s/
pushd crds/k8s/
curl --fail --remote-name -sSL https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/main/helm-charts/helm3/strimzi-kafka-operator/crds/\{040-Crd-kafka,041-Crd-kafkaconnect,042-Crd-strimzipodset,043-Crd-kafkatopic,044-Crd-kafkauser,045-Crd-kafkamirrormaker,046-Crd-kafkabridge,047-Crd-kafkaconnector,048-Crd-kafkamirrormaker2,048-Crd-kafkamirrormaker2,049-Crd-kafkarebalance\}.yaml
popd

Expected Behavior

Valid typescript code

Actual Behavior

Invalid typescript code

Output of pulumi about

CLI          
Version      3.43.1
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host     
OS       darwin
Version  11.7
Arch     x86_64

This project is written in nodejs: executable='/usr/local/bin/node' version='v18.11.0'

Current Stack: [REDACTED]

TYPE                                                         URN
[STRIPPED]


Found no pending operations associated with [REDACTED]

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/maxemann96
User           maxemann96
Organizations  maxemann96, [REDACTED]

Pulumi locates its logs in /var/folders/3p/6t2fzpvj3g7gj3jtgqm4yt080000gn/T/ by default
warning: Failed to get information about the Pulumi program's dependencies: Could not find either /[REDACTED]/yarn.lock or /[REDACTED]/package-lock.json

The warning can be ignored since it is a npm workspace setup.

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

maxemann96 avatar Oct 24 '22 10:10 maxemann96

Hi @maxemann96, thanks for the issue. Am I correct in thinking here that the issue you are having is the names still having hyphens in front of their names? Or is there another problem with the generated typescript code? Thanks!

roothorp avatar Oct 26 '22 11:10 roothorp

Thanks for your answer. Typescript doesn't like the hyphens in front of the names. Removing the hyphens from my code fixed the issue for me, but I'm not using these flags in my environment to define some Java heap space constraints. I think removing the hyphens made the code possible unusable for people which are relying on specifying the heap space constraints, but I don't know if this can be fixed.

maxemann96 avatar Oct 26 '22 21:10 maxemann96

Should be an "easy" fix by checking if the key name is a valid JS/TS variable name, and if not wrapping it in quotes?

samox73 avatar Nov 18 '22 12:11 samox73

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

cleverguy25 avatar Aug 09 '24 23:08 cleverguy25

Re-opening as incorrectly identified as a fix for the v1.5.0 release.

rquitales avatar Sep 25 '24 23:09 rquitales