pkg icon indicating copy to clipboard operation
pkg copied to clipboard

update-codegen.sh doesn't work outside GOPATH

Open ian-mi opened this issue 4 years ago • 8 comments

Expected Behavior

hack/update-codegen.sh should work outside of GOPATH

Actual Behavior

update-codegen either does nothing or uses an incorrect pkg version.

Steps to Reproduce the Problem

  1. Move repo outside of GOPATH.
  2. Make a change to the injection generators.
  3. Run ./hack/update-codegen.sh
  4. Observe no change to generated code.

ian-mi avatar May 04 '20 23:05 ian-mi

I'd love to see this happen too. Unfortunately this has to be tackled in the Kubernetes generators directly. The issue is that those generators always output to {{output-base}}/{{output-package}}/.

Technically, it does work outside of the GOPATH, but your repo needs to be cloned inside a directory matching -output-package exactly. For example, if your code is inside ~/my-knative-eventing and you set -output-base to ../../, all generated files will be written to

~/knative.dev/eventing/pkg/client/...

instead of

~/my-knative-eventing/pkg/client/...

because -output-package is set to knative.dev/eventing.

antoineco avatar May 05 '20 14:05 antoineco

/assign Cynocracy

I didn't see this before hitting the corner case myself :) I have a hacky attempt at a fix in knative.dev/networking, if it works I can upstream it into library.

Cynocracy avatar Jun 19 '20 05:06 Cynocracy

cc @n3wscott @ImJasonH

mattmoor avatar Jun 19 '20 14:06 mattmoor

This is a bug in gengo upstream in Kubernetes.

n3wscott avatar Jun 19 '20 14:06 n3wscott

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.

github-actions[bot] avatar Sep 18 '20 01:09 github-actions[bot]

/lifecycle frozen

I believe there's a hack @scothis had that created a temporary GOPATH in ./hack/update-codegen.sh that we could incorporate.

cc @Cynocracy

mattmoor avatar Sep 18 '20 01:09 mattmoor

I first saw this pattern in kpack. It basically involves setting up a fake GOPATH for gengo https://github.com/pivotal/kpack/blob/master/hack/update-codegen.sh#L16-L18

scothis avatar Sep 18 '20 15:09 scothis

Does this still repro with the new k8s library versions? I was really hoping it did not :(

Fake GOPATH sounds good, we've done similar things internally when we anger the great and powerful Go Mod.

Cynocracy avatar Sep 18 '20 22:09 Cynocracy