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

Duplicate declarations in generated Golang code #72

Closed
cstclair-tunein opened this issue Feb 3, 2022 · 5 comments
Closed

Duplicate declarations in generated Golang code #72

cstclair-tunein opened this issue Feb 3, 2022 · 5 comments
Assignees
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue

Comments

@cstclair-tunein
Copy link

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 cstclair-tunein added the kind/bug Some behavior is incorrect or out of spec label Feb 3, 2022
@danielrbradley danielrbradley added kind/bug Some behavior is incorrect or out of spec and removed kind/bug Some behavior is incorrect or out of spec labels Feb 8, 2022
@danielrbradley
Copy link
Member

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?

@dragos240
Copy link

dragos240 commented Feb 24, 2022

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.

@mattolenik mattolenik added the area/codegen Affects quality or correctness of generated code label Jun 2, 2022
@benglewis
Copy link

benglewis commented May 19, 2024

@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

@cleverguy25
Copy link

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

@mjeffryes mjeffryes self-assigned this Sep 6, 2024
@mjeffryes mjeffryes added the resolution/duplicate This issue is a duplicate of another issue label Sep 6, 2024
@mjeffryes
Copy link
Member

this is the same as #104

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 kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

7 participants