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

goPath not worked #89

Closed
howieyuen opened this issue Jul 13, 2022 · 4 comments · Fixed by #143
Closed

goPath not worked #89

howieyuen opened this issue Jul 13, 2022 · 4 comments · Fixed by #143
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@howieyuen
Copy link

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 howieyuen added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jul 13, 2022
@roothorp
Copy link

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 roothorp removed the needs-triage Needs attention from the triage team label Jul 14, 2022
@howieyuen
Copy link
Author

howieyuen commented Jul 14, 2022

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.

@cleverguy25
Copy link

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

5 participants