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

Install external hack/tools with a temporary go module #5569

Closed
sbueringer opened this issue Nov 2, 2021 · 4 comments · Fixed by #5741
Closed

Install external hack/tools with a temporary go module #5569

sbueringer opened this issue Nov 2, 2021 · 4 comments · Fixed by #5741
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@sbueringer
Copy link
Member

sbueringer commented Nov 2, 2021

We currently install all our hack/tool's via the hack/tools/go.mod go module. After a discussion in Slack (https://kubernetes.slack.com/archives/C8TSNPY4T/p1635440307207400) the consensus was that we want to install the tools via individual temporary go modules.

An example can be seen in CAPG: https://github.com/kubernetes-sigs/cluster-api-provider-gcp/blob/main/Makefile#L187-L188

Essentially, we ~ need the ./scripts/go_install.sh script and then the following in our Makefile (example kustomize):

KUSTOMIZE_VER := v3.8.6
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)

[...]
$(KUSTOMIZE): ## Build kustomize from tools folder.
	GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v3 $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)

I think the following tools can be installed this way:

  • setup-envtest
  • controller-gen
  • gotestsum
  • conversion-gen
  • go-apidiff
  • envsubst
  • yq
  • kustomize (should replace the shell script, as the shell script doesn't enforce the kustomize version)
  • golangci-lint (not sure about this one)

This helps us to avoid a monolithic hack/tools/go.mod file and after this change it only contains the dependencies of our local hack/tool's

Also this helps to make the version of our dependencies visible top-level (in the Makefile instead of hack/tools/go.mod)

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 2, 2021
@sbueringer sbueringer changed the title Install hack/tools with a temporary go module Install external hack/tools with a temporary go module Nov 2, 2021
@sbueringer
Copy link
Member Author

/area code-organization
/help

@k8s-ci-robot
Copy link
Contributor

@sbueringer:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/area code-organization
/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added area/code-organization help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Nov 2, 2021
@kaitoii11
Copy link
Contributor

/assign

@fabriziopandini
Copy link
Member

/milestone v1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants