Hello everyone, i found and try this project <htt...
# golang
m
Hello everyone, i found and try this project https://github.com/pulumi/crd2pulumi it’s amazing and thanks for it. But when I generate my pulumi type from crds it use code in the package
<http://github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes|github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes>
to reference internal package I think this is due to this https://github.com/pulumi/crd2pulumi/blob/master/pkg/codegen/golang.go#L54. My problem is that my pulumi code is elsewhere in a package named differently. Does i missed something with cli parameter or replace directive in my go.mod ? or should i do some sed after generation to adapt there imports ?
also this import path is legite to refer for example meta/v1 package. Moreover i don’t uderstand why a
pulumiTypes.go
is generated for Input indeed in my case the generated object
ObjectMetaArgs
is empty
b
this is likely a bug, could you possibly file an issue?
m
Thanks for answer 🙂 you mean the bug is to use
<http://github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes|github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes>
to reference internal package or that
ObjectMetaArgs
is empty ?
i will create issues according
b
the empty object, but likely both
m
issue created https://github.com/pulumi/crd2pulumi/issues/115 maybe i could help and contribute to fix it
I made some debugging and think that there is a problem with :
Copy code
const objectMetaRef = "#/types/kubernetes:meta/v1:ObjectMeta"
https://github.com/pulumi/crd2pulumi/blob/master/pkg/codegen/schema.go#L59 these ref is used for metadata type here https://github.com/pulumi/crd2pulumi/blob/master/pkg/codegen/packagegenerator.go#L181 and after this during import generation in pulumi codegen https://github.com/pulumi/pulumi/blob/master/pkg/codegen/go/gen.go#L2820 one case seems to be missing for
*schema.TokenType:
something like this maybe :
Copy code
case *schema.TokenType:
		if importExternal(t.Token) {
			break
		}
		mod := pkg.tokenToPackage(t.Token)
		if mod != pkg.mod {
			p := path.Join(pkg.importBasePath, mod)
			importsAndAliases[path.Join(pkg.importBasePath, mod)] = pkg.pkgImportAliases[p]
		}
but when i try this a second problem appear the function
importExternal
which use
isExternalReferenceWithPackage
don’t know how to deal with Token Type too here https://github.com/pulumi/pulumi/blob/master/pkg/codegen/go/gen.go#L625.
And now i failed to create PackageReference from
typ.Token
:
Copy code
case *schema.TokenType:
		pkg.tokenToPackage(typ.Token)
		typ.Token
		tokenToPackage()
		//	isExternal = typ.UnderlyingType != nil && !codegen.PkgEquals(typ.UnderlyingType, pkg.pkg)
		//	if isExternal {
		//		extPkg = typ.PackageReference
		//		token = typ.Token
		//	}
		return