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

build: install required binaries in a temporary subdirectory of the project #2335

Closed
lburgazzoli opened this issue May 27, 2021 · 4 comments
Closed

Comments

@lburgazzoli
Copy link
Contributor

If controller-gen or kustomize are not found, my understanding is that those binaries are downloaded and installed in $(GOBIN) which may lead to issues as it may override the version one has already downloaded:

# find or download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
	@{ \
	set -e ;\
	CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
	cd $$CONTROLLER_GEN_TMP_DIR ;\
	go mod init tmp ;\
	go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
	rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
	}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

kustomize:
ifeq (, $(shell which kustomize))
	@{ \
	set -e ;\
	KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
	cd $$KUSTOMIZE_GEN_TMP_DIR ;\
	go mod init tmp ;\
	go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\
	rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
	}
KUSTOMIZE=$(GOBIN)/kustomize
else
KUSTOMIZE=$(shell which kustomize)
endif

I think any project specific binary should be downloaded and installed on a temporary location relative to the project root

@lburgazzoli
Copy link
Contributor Author

@astefanutti what do you think ?

@astefanutti
Copy link
Member

@lburgazzoli my understanding is that overwriting only happens when GOBIN isn't in the PATH, which I would assume to be unusual. Otherwise, the existing version is used and not overwritten. That being said, I agree it'd be better to be completely environment independent, and install the binaries in temp dir local to the project.

@lburgazzoli
Copy link
Contributor Author

Ah yes, that should be how it works however I spotted the issue because my environment was non properly set up and GOBIN was non on the path for some unknown reasons so the first invocation leaded to my own controller-gen being replaced and being re-download at each make invocation.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale due to 90 days of inactivity.
It will be closed if no further activity occurs within 15 days.
If you think that’s incorrect or the issue should never stale, please simply write any comment.
Thanks for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants