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 Go package #104

Closed
Amit-Biderman opened this issue Nov 3, 2022 · 5 comments · Fixed by #143
Closed

Duplicate declarations in generated Go package #104

Amit-Biderman opened this issue Nov 3, 2022 · 5 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 kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@Amit-Biderman
Copy link

Amit-Biderman commented Nov 3, 2022

What happened?

Hello, I have a problem with crd2pulumi -
I have generated from the following crd - https://github.com/argoproj/argo-rollouts/blob/master/manifests/crds/rollout-crd.yaml - a pulumi package using the above command, and I got errors in the pulumiTypes.go file!
When I am running pulumi up, I get the following error message:

argoRollout/argoproj/v1alpha1/pulumiTypes.go:1842:6: RolloutSpecStrategyBluegreenPostpromotionanalysisArgs redeclared in this block argoRollout/argoproj/v1alpha1/pulumiTypes.go:1674:6: other declaration of RolloutSpecStrategyBluegreenPostpromotionanalysisArgs argoRollout/argoproj/v1alpha1/pulumiTypes.go:1917:98: v.Name undefined (type RolloutSpecStrategyBluegreenPostpromotionanalysisArgs has no field or method Name) argoRollout/argoproj/v1alpha1/pulumiTypes.go:1921:99: v.Value undefined (type RolloutSpecStrategyBluegreenPostpromotionanalysisArgs has no field or method Value) argoRollout/argoproj/v1alpha1/pulumiTypes.go:1926:12: v.ValueFrom undefined (type RolloutSpecStrategyBluegreenPostpromotionanalysisArgs has no field or method ValueFrom) argoRollout/argoproj/v1alpha1/pulumiTypes.go:2719:6: RolloutSpecStrategyBluegreenPrepromotionanalysisArgs redeclared in this block argoRollout/argoproj/v1alpha1/pulumiTypes.go:2551:6: other declaration of RolloutSpecStrategyBluegreenPrepromotionanalysisArgs argoRollout/argoproj/v1alpha1/pulumiTypes.go:2794:97: v.Name undefined (type RolloutSpecStrategyBluegreenPrepromotionanalysisArgs has no field or method Name) argoRollout/argoproj/v1alpha1/pulumiTypes.go:2798:98: v.Value undefined (type RolloutSpecStrategyBluegreenPrepromotionanalysisArgs has no field or method Value) argoRollout/argoproj/v1alpha1/pulumiTypes.go:4104:6: RolloutSpecStrategyCanaryAnalysisArgs redeclared in this block argoRollout/argoproj/v1alpha1/pulumiTypes.go:3926:6: other declaration of RolloutSpecStrategyCanaryAnalysisArgs argoRollout/argoproj/v1alpha1/pulumiTypes.go:5841:6: RolloutSpecStrategyCanaryStepsAnalysisArgs redeclared in this block argoRollout/argoproj/v1alpha1/pulumiTypes.go:5673:6: other declaration of RolloutSpecStrategyCanaryStepsAnalysisArgs argoRollout/argoproj/v1alpha1/pulumiTypes.go:6813:6: RolloutSpecStrategyCanaryStepsExperimentAnalysesArgs redeclared in this block argoRollout/argoproj/v1alpha1/pulumiTypes.go:6712:6: other declaration of RolloutSpecStrategyCanaryStepsExperimentAnalysesArgs argoRollout/argoproj/v1alpha1/pulumiTypes.go:2798:98: too many errors

I am taking from this that the crd2pulumi couldn’t create the package from the crd correctly.

Steps to reproduce

  1. Download the following crd - https://github.com/argoproj/argo-helm/blob/main/charts/argo-rollouts/templates/crds/rollout-crd.yaml
  2. Run the command: crd2pulumi --goName argoRollout --goPath ./argoRollout ./rollout-crd.yaml
  3. The generated package contains error in the pulumiTypes.go

Expected Behavior

The files generated are without duplicated declarations (specifically the pulumiTypes.go)

Actual Behavior

The files generated are with duplicated declarations (specifically the pulumiTypes.go)

Output of pulumi about

CLI
Version 3.37.2
Go Version go1.18.4
Go Compiler gc

Plugins
NAME VERSION
aws 5.13.0
gcp 6.34.0
go unknown
kubernetes 3.20.4
random 4.8.1

Host
OS darwin
Version 12.1
Arch arm64

This project is written in go: executable='/usr/local/go/bin/go' version='1.18.5 darwin/amd64'

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

@Amit-Biderman Amit-Biderman added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 3, 2022
@squaremo squaremo added area/codegen Affects quality or correctness of generated code area/schema Related to support for CRD or Pulumi schema support and removed needs-triage Needs attention from the triage team labels Nov 7, 2022
@squaremo
Copy link

squaremo commented Nov 7, 2022

Thank you for taking time to provide a full explanation, it's appreciated. I agree this looks like an outright bug, rather than e.g., not handling a tricky input.

@Amit-Biderman
Copy link
Author

Amit-Biderman commented Jun 27, 2024

Hey - still happening, can we please get an update on this issue? @squaremo

@cleverguy25
Copy link

@mjeffryes
Copy link
Member

A similar error occurs on https://raw.githubusercontent.com/cilium/tetragon/v1.2.0/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml

in both cases, the problem is that the crd has a field named "args", which is a suffix pulumi uses when generating the input structs. Thus a crd with fields like:

...
kprobes:
  description: A list of kprobe specs.
  items:
    properties:
      args:
...

Tries to create:

type Kprobes struct {...} // Outer object type
type KprobesArgs struct {...} // Outer object's Input/Arguments type
type KprobesArgs struct {...} // Inner object type
type KprobesArgsArgs struct {...} // Inner object's Input/Arguments type

Which results in a collision

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

Successfully merging a pull request may close this issue.

6 participants