crd2pulumi icon indicating copy to clipboard operation
crd2pulumi copied to clipboard

Duplicate declarations in generated Golang code

Open cstclair-tunein opened this issue 3 years ago • 3 comments

Hello!

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

Issue details

When one attempts to use the crd2pulumi binary to generate a library from a CRD, the GoLang code errors due to duplicate declarations. Example image attached.

Screen Shot 2022-02-03 at 3 10 59 PM

Steps to reproduce

  1. Grab the ArgoRollout CRD declarations located here
  2. Initialize your pulumi stack
  3. Run crd2pulumi --goPath ./internal/argorollouts install.yaml

Expected: Pulumi will generate a working Golang implementation of the CRD Actual: The GoLang generated by Pulumi is not valid.

cstclair-tunein avatar Feb 03 '22 23:02 cstclair-tunein

Hi, thanks for filing this issue. Do you currently have a workaround?

Do you have any suspicion why it's generating it twice for this CRD - have you seen this issue with other CRDs?

danielrbradley avatar Feb 08 '22 17:02 danielrbradley

I'm getting this kind of thing with the Python generation. It specifically occurs in outputs.py and _inputs.py. Examples:

        File "venv/path/lib/python3.8/site-packages/pulumi_crds/networking/v1beta1/outputs.py", line 3680
          def __init__(__self__, *,
          ^
      SyntaxError: duplicate argument 'mirror_percent' in function definition
      
        File "venv/path/lib/python3.8/site-packages/pulumi_crds/networking/v1beta1/_inputs.py", line 4536
          def __init__(__self__, *,
          ^
      SyntaxError: duplicate argument 'mirror_percent' in function definition
      
        File "venv/path/lib/python3.8/site-packages/pulumi_crds/networking/v1alpha3/outputs.py", line 3870
          def __init__(__self__, *,
          ^
      SyntaxError: duplicate argument 'mirror_percent' in function definition
      
        File "venv/path/lib/python3.8/site-packages/pulumi_crds/networking/v1alpha3/_inputs.py", line 4703
          def __init__(__self__, *,
          ^
      SyntaxError: duplicate argument 'mirror_percent' in function definition
      
        File "venv/path/lib/python3.8/site-packages/pulumi_crds/security/v1beta1/outputs.py", line 244
          def __init__(__self__, *,
          ^
      SyntaxError: duplicate argument 'jwks_uri' in function definition
      
        File "venv/path/lib/python3.8/site-packages/pulumi_crds/security/v1beta1/_inputs.py", line 186
          def __init__(__self__, *,
          ^
      SyntaxError: duplicate argument 'jwks_uri' in function definition

My solution is just to manually remove the duplicate parameters from the generated code and it works.

EDIT: I'm using CRDs for Istio and cert-manager, which both have this issue.

dragos240 avatar Feb 24 '22 15:02 dragos240

@dragos240 I am doing the exact same thing and finding the same problem. @danielrbradley Do you have any plans to fix this? I may be able to take a look at the GoLang code and try to fix it, but I have no experience whatsoever in GoLang, so I'm not 100% sure how easy it would be for me :/ In the meantime, the manual fix is OK

benglewis avatar May 19 '24 10:05 benglewis

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

cleverguy25 avatar Aug 09 '24 23:08 cleverguy25

this is the same as https://github.com/pulumi/crd2pulumi/issues/104

mjeffryes avatar Sep 06 '24 20:09 mjeffryes