Commit graph

100 commits

Author SHA1 Message Date
Kevin Hannon
fda069a5d6 update kal to fix markdown table bug 2025-10-30 12:01:09 -04:00
yongruilin
12b5106809 bump kube-api-linter tool to latest and go mod tidy 2025-10-22 18:02:06 +00:00
Stephen Kitt
c3a26a066d
Bump golangci-lint to 2.4.0
This adds support for Go 1.25. There are no changes to the linting
results.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-09-18 16:20:34 +02:00
Benjamin Elder
88d6e6c465 drop automaxprocs hacks now that go 1.25 handles this built in
https://go.dev/doc/go1.25#container-aware-gomaxprocs
2025-09-17 16:36:15 -07:00
Benjamin Elder
563d4d651c bump go language version to 1.25 2025-09-17 14:56:07 -07:00
Joel Speed
e3b08f9871
Update KAL to latest and add shadow config for new options 2025-09-12 18:06:17 +01:00
Stephen Kitt
81cec6df1d
Bump to mockery v3
mockery has introduced breaking changes and switched to a v3 branch,
this migrates to that, mostly using the built-in migration tool. Mocks
are now generated in single files per package, except in packages
containing mocks for multiple interface packages (in
pkg/kubelet/container/testing).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-08-29 13:43:54 +02:00
Keisuke Ishigami
a2061e97f4 install appropriate version 2025-08-03 01:47:34 +09:00
Keisuke Ishigami
6852abc73c WIP: Use the tool directive instead of tools.go without sharing dependency 2025-07-31 00:45:27 +09:00
Tim Hockin
7adcd21148
Replace cmd/yamlfmt with k-sigs/yaml/yamlfmt
And run it.
2025-07-24 12:11:04 -07:00
Kubernetes Prow Robot
9a50e30636
Merge pull request #132668 from dims/fix-todos-from-sorted-features-original-pr
Fix todos from sorted features golangci-lint plugin PR
2025-07-09 13:15:26 -07:00
Sascha Grunert
b464bbeb8f
Remove gogo-protobuf from CRI
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2025-07-04 08:55:57 +02:00
Davanum Srinivas
1514568ddf
rename sortedfeatures -> sorted
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-07-01 22:12:26 -04:00
Davanum Srinivas
9e1a21816d
update README
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-07-01 22:03:22 -04:00
Davanum Srinivas
5cebe66b64
update log line
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-07-01 21:57:50 -04:00
Davanum Srinivas
f2d8b7ec2c
Add linter to report on unsorted feature gates
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-06-27 11:05:13 -04:00
Joel Speed
2f50d0a510
Add kube-api-linter plugin to golangci-lint 2025-05-16 16:04:15 +01:00
Patrick Ohly
0faeb5a0d0 golangci-lint: move into hack/tools/golangci-lint
The advantage is that it separates the dependencies of the different tools
better. golangci-lint in particular has many dependencies and is sometimes
sensitive to the exact version being used. This way, "go get" bumps up
dependencies exactly as defined by the upstream golangci-lint module.

It's not quite self-contained because logcheck as a Go plugin for golangci-lint
must be built from the same dependencies. But it only adds one and does not
change any of the others.

While at it, the Go 1.24 "tools" directive gets used instead of the traditional
tools.go approach.
2025-05-02 14:38:09 +02:00
Matthieu MOREL
4adb58565c chore: bump golangci-lint to v2
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-02 12:51:02 +02:00
Patrick Ohly
8bb7b05637 dependencies: github.com/client9/misspell -> github.com/golangci/misspell
github.com/client9/misspell was archived by the owner on Mar 26, 2025.
The golangci-lint team maintains a fork.

The newer code finds some misspellings which where missed before.
2025-04-28 15:44:04 +02:00
Benjamin Elder
1473aeaac4 add goimports to tools module
used by go-to-protobuf, currently we rely on the host copy ...
2025-04-24 22:54:09 -07:00
zhangzhifei16
c1ff9cf4e8 chore: Upgrade the mockery version to v2.53.3. 2025-04-10 21:16:47 +08:00
Jordan Liggitt
43509b63d7
Bump hack/tools to github.com/golangci/golangci-lint 1.64.5 for go 1.24 2025-02-26 11:27:14 +01:00
cpanato
88300c406b
bump go.mod to set min go1.24
Signed-off-by: cpanato <ctadeu@gmail.com>
2025-02-26 11:27:07 +01:00
Jordan Liggitt
102a9dbab1
Pin godebug default to go1.23 2024-09-11 15:34:37 -04:00
Jordan Liggitt
65ef531390
Update go.mod to go 1.23 2024-09-11 15:34:37 -04:00
Akhil Mohan
b0bf3fba54
rewrite publishing-bot verify script in go
- setup scripts to trigger publishing-bot verify
- add golang verify script and remove python verification code
- pin k8s.io/publishing-bot to v0.5.0

Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
2024-09-06 09:30:51 +05:30
Patrick Ohly
a7da865aa8 test: filter "go test" output with gotestsum instead of grep
Filtering the output with grep leads to hard to read log output, e.g. from
pull-kubernetes-unit:

    +++ [0613 15:32:48] Running tests without code coverage and with -race
    {"Time":"2024-06-13T15:33:47.845457374Z","Action":"output","Package":"k8s.io/kubernetes/cluster/gce/cos","Test":"TestCreateMasterAuditPolicy","Output":"        /tmp/configure-helper-test47992121/kube-env: line 1: `}'\n"}
    {"Time":"2024-06-13T15:33:49.053732803Z","Action":"output","Package":"k8s.io/kubernetes/cluster/gce/cos","Output":"ok  \tk8s.io/kubernetes/cluster/gce/cos\t2.906s\n"}

We can do better than that. When feeding the output of the "go test" command(s)
into gotestsum *while it runs*, we can use --format=standard-quiet (= normal go
test output) or --format=standard-verbose (= `go test -v`) when FULL_LOG is
requested to get nicer output.

This works when testing everything at once. This was said to be not possible
when doing coverage profiling. But recent Go no longer has that limitation, so
the xargs trick gets removed. All that we need to do for coverage profiling is
to add some additional parameters and the conversion to HTML.
2024-08-19 16:14:05 +02:00
Madhav Jivrajani
6b7b36a4ad hack/tools: bump go-tools for go1.23.0
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
2024-08-15 21:56:10 -05:00
fsl
99680bfd76 hack/tools: bump google.golang.org/protobuf to v1.31.0 for v1.34.2
Signed-off-by: fengshunli <1171313930@qq.com>
2024-07-20 03:40:40 +08:00
Madhav Jivrajani
92f5b08f8c hack/tools: bump go-tools to v0.5.0-rc.1 for go1.23
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
2024-07-15 15:03:10 +05:30
Stephen Kitt
3f36c83c68
Switch to stretchr/testify / mockery for mocks
testify is used throughout the codebase; this switches mocks from
gomock to testify with the help of mockery for code generation.

Handlers and mocks in test/utils/oidc are moved to a new package:
mockery operates package by package, and requires packages to build
correctly; test/utils/oidc/testserver.go relies on the mocks and fails
to build when they are removed. Moving the interface and mocks to a
different package allows mockery to process that package without
having to build testserver.go.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-06-20 19:42:53 +02:00
Monis Khan
974e2d956e
Ignore go.work.sum for fake workspaces
Signed-off-by: Monis Khan <mok@microsoft.com>
2024-05-16 13:52:36 -04:00
jwcesign
f0aa62bc96 upgrade: upgrade dependencies github.com/prometheus/common to the newest version
Signed-off-by: jwcesign <jwcesign@gmail.com>
2024-04-20 09:53:16 +08:00
Stephen Kitt
6bf667af06
Switch from golang/mock to uber-go/mock
See https://github.com/golang/mock#gomock: golang/mock is no longer
maintained, and should be replaced by go.uber.org/mock.

This allows golang/mock to be dropped from the status and vendored
fields in unwanted-dependencies.json.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-03-07 09:12:16 +01:00
Patrick Ohly
65b841c077
Generate go.work files
This creates go.work and enables Go Workspaces.  This is a file that
includes info on k/k and all the staging modules.

This depends on go 1.22 and setting FORCE_HOST_GO=true (for kube
scripts, which try to be hermetic).

Make this part of the normal update/verify sequence.

The top-level go.work file contains no replace statements. Instead, the
replace statements in the individual go.mod files are used. For this to
work, replace statements in the individual go.mod files have to be
consistent.

hack/tools has different dependencies and can't be in the main
workspace, so this adds a go.work just for that.  Without this, go tries
to consider all deps in all modules and pick one that works for all.
This is problematic because there are so many of them that it is
difficult to manage.

Likewise for k8s.io/code-generator/examples and
k8s.io/kms/internal/plugins/_mock - add trivial go.work files.

For example k/k depends on an older version of a lib that gloangci-lint
needs (transitively) and it breaks.

This also updates vendor (needed to make go happy), and removes
vendor'ed symlinks.  This breaks a LOT of our build tools, which will be
fixed subsequently.

Result: `go` commands work across modules:

Before:
```
$ go list ./pkg/proxy/iptables/ ./staging/src/k8s.io/api/core/v1/
main module (k8s.io/kubernetes) does not contain package k8s.io/kubernetes/staging/src/k8s.io/api/core/v1

$ go build ./pkg/proxy/iptables/ ./staging/src/k8s.io/api
main module (k8s.io/kubernetes) does not contain package k8s.io/kubernetes/staging/src/k8s.io/api

$ go test ./pkg/proxy/iptables/ ./staging/src/k8s.io/api
main module (k8s.io/kubernetes) does not contain package k8s.io/kubernetes/staging/src/k8s.io/api
```

After:
```
$ go list ./pkg/proxy/iptables/ ./staging/src/k8s.io/api/core/v1/
k8s.io/kubernetes/pkg/proxy/iptables
k8s.io/api/core/v1

$ go build ./pkg/proxy/iptables/ ./staging/src/k8s.io/api

$ go test ./pkg/proxy/iptables/ ./staging/src/k8s.io/api
ok  	k8s.io/kubernetes/pkg/proxy/iptables	0.360s
ok  	k8s.io/api	2.302s
```

Result: `make` fails:

```
$ make
go version go1.22rc1 linux/amd64
+++ [0106 12:11:03] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kube-proxy (static)
    k8s.io/kubernetes/cmd/kube-apiserver (static)
    k8s.io/kubernetes/cmd/kube-controller-manager (static)
    k8s.io/kubernetes/cmd/kubelet (non-static)
    k8s.io/kubernetes/cmd/kubeadm (static)
    k8s.io/kubernetes/cmd/kube-scheduler (static)
    k8s.io/component-base/logs/kube-log-runner (static)
    k8s.io/kube-aggregator (static)
    k8s.io/apiextensions-apiserver (static)
    k8s.io/kubernetes/cluster/gce/gci/mounter (static)
    k8s.io/kubernetes/cmd/kubectl (static)
    k8s.io/kubernetes/cmd/kubectl-convert (static)
    github.com/onsi/ginkgo/v2/ginkgo (non-static)
    k8s.io/kubernetes/test/e2e/e2e.test (test)
    k8s.io/kubernetes/test/conformance/image/go-runner (non-static)
    k8s.io/kubernetes/cmd/kubemark (static)
    github.com/onsi/ginkgo/v2/ginkgo (non-static)
    k8s.io/kubernetes/test/e2e_node/e2e_node.test (test)
test/e2e/e2e.go:35:2: cannot find package "k8s.io/api/apps/v1" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/api/apps/v1 (vendor tree)
	/home/thockin/src/kubernetes/_output/local/.gimme/versions/go1.22rc1.linux.amd64/src/k8s.io/api/apps/v1 (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/api/apps/v1 (from $GOPATH)
	... more ...
	... more ...
	... more ...
!!! [0106 12:13:41] Call tree:
!!! [0106 12:13:41]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:948 kube::golang::build_binaries_for_platform(...)
!!! [0106 12:13:41]  2: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0106 12:13:41] Call tree:
!!! [0106 12:13:41]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0106 12:13:41] Call tree:
!!! [0106 12:13:41]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:96: all] Error 1
```

Again, this requires go 1.22 (e.g. gotip), as go 1.21.x does not have
`go work vendor` support.

TO REPEAT:
    ( \
      ./hack/update-go-workspace.sh; \
      ./hack/update-vendor.sh; \
      ./hack/update-go-workspace.sh; \
    )
2024-02-29 00:22:06 -08:00
Kay Yan
78c9610235 hack/tools: update to golangci-lint v1.56.2 + golang v1.21
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2024-02-22 07:03:10 +00:00
José Carlos Chávez
6d6398ef92
chore: adds consistent vanity import to files and provides tooling for verifying and updating them. (#120642)
* chore: drops update vanity imports from script.

* chore: changes copyright year to 2024.

* chore: makes lint happy.
2024-02-08 04:33:30 -08:00
Patrick Ohly
d954b25b11 hack/tools: bump logcheck to v0.8.1
This enables the usage of the new SafePtr in code which needs to support
contextual logging.
2024-01-12 14:39:50 +01:00
Davanum Srinivas
2431a964af
Drop hack/verify-govet-levee
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-01-04 21:06:52 -05:00
Patrick Ohly
51f3b705c6 hack/tools: bump logtools to v0.8.0
This adds support for marking functions and methods as "don't use in code which
supports contextual logging".
2023-12-21 15:12:40 +01:00
Patrick Ohly
49084fe577 golangci-lint: logcheck v0.7.0, golangci-lint v1.55.2
This adds support for the new golangci-lint plugin interface and settings
mechanism.
2023-12-14 20:21:19 +01:00
Patrick Ohly
27f6fb2fa7 hack/tools: golangci-lint v1.55.1
No particular reason for updating to it besides staying up-to-date. The new
checks in the updated ginkgolinter found issues.
2023-10-26 15:32:43 +02:00
Patrick Ohly
9742e276b9 update to golangci-lint v1.54.1 + go-ruleguard v0.4.0
That release is the first one with official support for Go 1.21. go-ruleguard
must be >= 0.3.20 because of
https://github.com/quasilyte/go-ruleguard/issues/449 with Go
1.21. golangci-lint itself doesn't depend on a recent enough release yet, so
this was done manually.
2023-08-16 09:07:30 +02:00
Madhav Jivrajani
6fd830a075 hack/tools: bump golangci-lint and consequently staticcheck
This bump is done since the latest version of staticcheck includes
a fix for a false positive reported by us, discovered while bumping
to go1.20

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
2023-06-27 14:20:41 +02:00
Jordan Liggitt
b9950b5192
Drop zeitgeist from tools go.mod 2023-05-17 08:37:53 -04:00
Patrick Ohly
1ea17254bf hack/tools: bump logcheck to v0.5.0 2023-05-11 16:54:26 +02:00
Davanum Srinivas
5662566e03
Set GOMAXPROCS explicitly
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-03-30 20:26:07 -04:00
Patrick Ohly
443b1c6c23 hack/tools: bump golangci-lint to v1.51.2 2023-02-22 07:54:20 +01:00
Madhav Jivrajani
64cf942ce8 hack/tools: Bump golangci-lint version
Bump golangci-lint version. This version
adds support for go1.20.

This consequently also bumps the version of
staticcheck. Note that this was changed to
use master to be compatible with 1.20. This
commit reverts back to using a tagged release.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
2023-02-06 12:27:16 +05:30