crd2pulumi icon indicating copy to clipboard operation
crd2pulumi copied to clipboard

goPath not worked

Open howieyuen opened this issue 2 years ago • 2 comments

What happened?

crd2pulumi --goPath ./crontabs crontab.yaml generate code under package kubernetes not under crontabs

Steps to reproduce

Just like README says, prepare crontab.yaml first, then run crd2pulumi --goPath ./crontabs crontab.yaml

Expected Behavior

generated code under new package crontabs

Actual Behavior

generated code under new package kubernetes

Versions used

v1.2.0

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

howieyuen avatar Jul 13 '22 08:07 howieyuen

Hi @howieyuen , we have reproduced this issue and can confirm this is a bug. This bug only seems present for Go, and the equivalent flags for other languages are functional. This portion of the codebase seems to have undergone quite a lot of changes since the last release, so the issue might have already been addressed. @mattolenik would be good to confirm whether this has been addressed?

roothorp avatar Jul 14 '22 12:07 roothorp

Hi @howieyuen , we have reproduced this issue and can confirm this is a bug. This bug only seems present for Go, and the equivalent flags for other languages are functional. This portion of the codebase seems to have undergone quite a lot of changes since the last release, so the issue might have already been addressed. @mattolenik would be good to confirm whether this has been addressed?

I try to fix locally, but failed 😭 I puase here pkg/codegen/golang.go:75:

func GenerateGo(pg *PackageGenerator, name string) (buffers map[string]*bytes.Buffer, err error) {
        ...
	for path, code := range files {
		newPath, _ := filepath.Rel(name, path)

and see newPath is ../kubernetes/xxx, I don't know the intension of filepath.Rel(), but after that, back to parent func at pkg/codegen/codegen.go:86:

func writeFiles(files map[string]*bytes.Buffer, outputDir string) error {
	for path, code := range files {
		outputFilePath := filepath.Join(outputDir, path)

        ...

the outputFilePath comes from filepath.Join("crontabs","../kubernetes"), and it turns out kubernetes.

howieyuen avatar Jul 14 '22 13:07 howieyuen

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

cleverguy25 avatar Aug 09 '24 23:08 cleverguy25