Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid typescript code produced when generating for strimzi crds #103

Open
maxemann96 opened this issue Oct 24, 2022 · 6 comments · Fixed by #143
Open

Invalid typescript code produced when generating for strimzi crds #103

maxemann96 opened this issue Oct 24, 2022 · 6 comments · Fixed by #143
Assignees
Labels
area/codegen Affects quality or correctness of generated code area/schema Related to support for CRD or Pulumi schema support impact/accessibility Something that is difficult or impossible for some people to use kind/bug Some behavior is incorrect or out of spec

Comments

@maxemann96
Copy link

maxemann96 commented Oct 24, 2022

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 maxemann96 added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Oct 24, 2022
@roothorp
Copy link

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 roothorp added awaiting-feedback Blocked on input from the author impact/accessibility Something that is difficult or impossible for some people to use area/schema Related to support for CRD or Pulumi schema support area/codegen Affects quality or correctness of generated code and removed needs-triage Needs attention from the triage team labels Oct 26, 2022
@maxemann96
Copy link
Author

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.

@samox73
Copy link

samox73 commented Nov 18, 2022

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?

@cleverguy25
Copy link

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

@rquitales
Copy link
Member

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

@rquitales rquitales reopened this Sep 25, 2024
@pulumi-bot
Copy link

This issue has been addressed in PR #143 and shipped in release v1.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen Affects quality or correctness of generated code area/schema Related to support for CRD or Pulumi schema support impact/accessibility Something that is difficult or impossible for some people to use kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants