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

[Golang] bad import package and empty shaded type #115

Closed
RouxAntoine opened this issue Sep 6, 2023 · 3 comments · Fixed by #143
Closed

[Golang] bad import package and empty shaded type #115

RouxAntoine opened this issue Sep 6, 2023 · 3 comments · Fixed by #143
Assignees
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec language/go resolution/fixed This issue was fixed

Comments

@RouxAntoine
Copy link

RouxAntoine commented Sep 6, 2023

What happened?

I generate pulumi type for certmanager crd with command :

crd2pulumi --go ../../../kubeadm/cert-manager/cert-manager/1-crds.yaml

Expected Behavior

i expected that i can create a new Certificate with NewCertificate

when i build with pulumi up it give me

--> pulumi up
Previewing update (prod):
     Type                 Name        Plan     Info
     pulumi:pulumi:Stack  infra-prod           1 error; 2 warnings; 2 messages


Diagnostics:
  pulumi:pulumi:Stack (infra-prod):
    warning: using pulumi-language-go from $PATH at /opt/homebrew/bin/pulumi-language-go
    warning: using pulumi-language-go from $PATH at /opt/homebrew/bin/pulumi-language-go
    error: error in compiling Go: unable to run `go build`: exit status 1

    go: updates to go.mod needed; to update it:
        go mod tidy

when i look at generated code :

it use in import metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"

but my pulumiTypes.go is in package v1

so Metadata metav1.ObjectMetaPtrOutput 'pulumi:"metadata"'

same in pulumi/crds/kubernetes/certmanager/v1/init.go it use version, err := kubernetes.PkgVersion() with import "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes"

Steps to reproduce

the certmanager's crds come from official github but it was maybe a little bit outdated. So i joined it

https://gist.github.com/RouxAntoine/b7dfb9ce327a4ad40a76ff6552c7fd5e

Output of pulumi about

--> pulumi about
CLI          
Version      3.80.1-dev.0
Go Version   go1.21.0
Go Compiler  gc

Host     
OS       darwin
Version  13.5.1
Arch     arm64

Backend        
Name           xxx
URL            xxx
User           antoine
Organizations  

Pulumi locates its logs in /tmp by default
warning: Failed to read project: no Pulumi.yaml project file found (searching upwards from /Users/antoine/Documents/go/projects/crd2pulumi). If you have not created a project yet, use `pulumi new` to do so: no project file found
warning: Failed to get information about the current stack: no Pulumi.yaml project file found (searching upwards from /Users/antoine/Documents/go/projects/crd2pulumi). If you have not created a project yet, use `pulumi new` to do so: no project file found

Additional context

i try some tweek in this branch https://github.com/pulumi/crd2pulumi/compare/master...RouxAntoine:crd2pulumi:feature/upgrade-dependencies-sdk-to-v4?expand=1#

and by disabling type shading in packagegenerator.go line 118 genPackage(pg.Version, pg.Types, pg.ResourceTokens, false) false as last parameter it well suite in import but the shaded type ObjectMetaPtrOutput for exemple is unknown du to missing import.

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

Thanks for this tools, Best regards

@RouxAntoine RouxAntoine added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Sep 6, 2023
@mikhailshilkov mikhailshilkov added language/go area/codegen Affects quality or correctness of generated code and removed needs-triage Needs attention from the triage team labels Sep 8, 2023
@cleverguy25
Copy link

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

@pulumi-bot
Copy link

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

@RouxAntoine
Copy link
Author

Hello @cleverguy25 I only tested it now, but everything is ok, thanks, you rock

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 language/go resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants