Skip to content

Use the tool directive instead of tools.go without sharing dependency in hack/tools #133315

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kei01234kei
Copy link
Contributor

@kei01234kei kei01234kei commented Jul 30, 2025

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR is related to:

#133316

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 30, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @kei01234kei. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 30, 2025
@k8s-ci-robot k8s-ci-robot requested review from mikedanese, SataQiu and a team July 30, 2025 15:46
@k8s-ci-robot k8s-ci-robot added the area/dependency Issues or PRs related to dependency changes label Jul 30, 2025
@kei01234kei kei01234kei changed the title WIP: Use the tool directive instead of tools.go without sharing depen… WIP: Use the tool directive instead of tools.go without sharing dependency Jul 30, 2025
@BenTheElder
Copy link
Member

/assign

sigs.k8s.io/yaml v1.6.0 // indirect
)

tool (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did like the comments on the tools.go imports explaining the use... any chance we can include comments here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we can't add comments like this because go mod tidy automatically sorts the dependencies alphabetically, which messes up the comment grouping.

tool (
	// linting tools
	github.com/aojea/sloppy-netparser
	github.com/golangci/misspell
	github.com/jcchavezs/porto/cmd/porto
	honnef.co/go/tools/cmd/staticcheck

	// benchmarking tools
	github.com/cespare/prettybench
	gotest.tools/gotestsum
	...
)

While we can add comments in this format, it feels like go.mod isn't the right place for human-written comments anyway. If we want to keep notes on these tools, it would probably be better to put them in a README.md file under hack/tools.

tool (
    github.com/aojea/sloppy-netparser // linting tools
    github.com/cespare/prettybench // benchmarking tools
    github.com/golangci/misspell // linting tools
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's too bad. but at least we can just search for scripts referencing these paths

@liggitt
Copy link
Member

liggitt commented Jul 30, 2025

I'm not sure what "Don't share the tool dependencies" means ... the dependencies are still shared, I think

@kei01234kei
Copy link
Contributor Author

kei01234kei commented Jul 30, 2025

I'm not sure what "Don't share the tool dependencies" means ... the dependencies are still shared, I think

This means we should avoid using the tool directive in the repository's root go.mod file so that tool dependencies are not shared with the main Kubernetes module's dependencies.
(I modified the issue comment.)


tool (
github.com/aojea/sloppy-netparser
github.com/cespare/prettybench
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait... does this lose us the ability to specify which version of a tool we want to use? I wouldn't have expected any versions in the go.mod file or go.sum file to change if all we're doing is reorganizing where we record the tools / versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't have expected any versions in the go.mod file or go.sum file to change if all we're doing is reorganizing where we record the tools / versions

You're right. This PR initially also updated the tool modules. That happened because I didn't specify their versions when moving them to the tool directive, so Go defaulted to fetching the latest ones.
I've already fixed this in the latest commit by reverting them to their original versions.
install appropriate version

@kei01234kei kei01234kei force-pushed the use_go_tool_instead_of_tools_go_without_sharing_dependency branch from 34f8233 to e39983c Compare August 2, 2025 16:46
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 2, 2025
@kei01234kei kei01234kei force-pushed the use_go_tool_instead_of_tools_go_without_sharing_dependency branch from e39983c to a2061e9 Compare August 2, 2025 16:47
@liggitt liggitt marked this pull request as ready for review August 2, 2025 17:17
@liggitt
Copy link
Member

liggitt commented Aug 2, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot requested review from BenTheElder, justaugustus and a team August 2, 2025 17:17
@liggitt
Copy link
Member

liggitt commented Aug 2, 2025

/sig architecture
/area code-organization
/milestone v1.35

this lgtm, will see how happy CI is

@k8s-ci-robot k8s-ci-robot added this to the v1.35 milestone Aug 2, 2025
@k8s-ci-robot k8s-ci-robot added sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. area/code-organization Issues or PRs related to kubernetes code organization and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 2, 2025
@kei01234kei
Copy link
Contributor Author

/retest

@liggitt
Copy link
Member

liggitt commented Aug 5, 2025

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: f3986e88ac705a913b0ffdfa389f87b56c90e4ba

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kei01234kei, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2025
@BenTheElder
Copy link
Member

/kind cleanup
/release-note-none
/triage accepted

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 5, 2025
@BenTheElder
Copy link
Member

/sig testing

@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Aug 5, 2025
@kei01234kei kei01234kei changed the title WIP: Use the tool directive instead of tools.go without sharing dependency Use the tool directive instead of tools.go without sharing dependency in hack/tools Aug 6, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 6, 2025
@kei01234kei
Copy link
Contributor Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 6, 2025
@kei01234kei
Copy link
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/code-organization Issues or PRs related to kubernetes code organization area/dependency Issues or PRs related to dependency changes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants