Skip to content

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

@RouxAntoine

Description

@RouxAntoine

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

Metadata

Metadata

Assignees

Labels

area/codegenAffects quality or correctness of generated codekind/bugSome behavior is incorrect or out of speclanguage/goresolution/fixedThis issue was fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions