Commit Graph

68 Commits

Author SHA1 Message Date
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
Patrick Ohly
1d79a191c2 hack: update logtools to v0.4.1
Contains some bug fixes, for example allowing some additional
functions when enforcing contextual logging.
2023-01-23 14:24:29 +01:00
Jordan Liggitt
121088cb2a
bump honnef.co/go/tools to support go1.20 2023-01-17 10:42:55 -05:00
Oscar Utbult
de1fff9afa hack/tools: update golangci-lint version (1.48.0 -> 1.50) 2022-10-20 13:51:10 +02:00
Abirdcfly
c8c5539e76
update golangci-lint for go 1.19
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-08-07 12:01:15 +08:00
Jordan Liggitt
00db9f0229 Update go.mod to go1.19 2022-08-04 10:03:05 -04:00
Davanum Srinivas
34742f2d2e
run lint-dependencies and follow directions
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-08-03 22:00:02 -04:00
Davanum Srinivas
30e2fcd041
Stop panic in govet-levee CI job
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-08-03 21:51:01 -04:00
Abirdcfly
2bca77a3d9 Update golangci-lint to 1.46.2 and fix errors
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-06-29 17:42:46 +08:00
Patrick Ohly
0284c6c06e hack/tools: use logcheck v0.1.0 from sigs.k8s.io/logtools/logcheck
The code was moved out of k8s.io/klog into its own repo with proper
tagging. Functionally there is no difference.
2022-06-14 17:27:16 +02:00
Jordan Liggitt
9e1064a26b Regenerate vendor 2022-05-04 10:27:41 -04:00
Jordan Liggitt
1176b7ca28 Update go.mod files to go1.18, update license vendor script 2022-05-04 10:22:27 -04:00
Patrick Ohly
17e3c555c5 hack: integrate logcheck into golangci-lint
Running logcheck as part of golangci-lint has several advantages:
- faster checking because finding files and parsing is shared
  with other linters
- gets rid of the complex and buggy
  hack/verify-structured-logging.sh (https://github.com/kubernetes/kubernetes/issues/106746)
- support for // nolint:logcheck
- works with Go 1.18
2022-03-24 11:21:03 +01:00
Kir Kolyshkin
e3ed3ba7c9 update golangci-lint to 1.45.0
This should fix Go 1.18 compatibility woes.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-03-23 10:19:16 -07:00
Tim Hockin
e671fea954 Remove hack/tools/Makefile 2022-02-26 12:57:10 -08:00
Umanga Chapagain
f4ff6984cf
update hack/tools to pull latest logcheck
Signed-off-by: Umanga Chapagain <chapagainumanga@gmail.com>
2021-10-05 15:55:58 +05:30
Vikram Jadhav
5f674101bb Added update and verify scripts for automated mock generation 2021-09-03 17:40:11 +00:00
Antonio Ojea
06f2d678ee update and verify netparse
Add script to verify that net.ParseIP and net.ParseCIDR are
not being used.

Add another script to automatically replace those functions
for the ones forked in k8s.io/utils/net
2021-08-20 10:42:09 +02:00
Davanum Srinivas
b74fe232e3
update golangci-lint to newer version
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-07-14 08:41:21 -04:00
Mikhail Mazurskiy
bc475373b2
Drop direct dependency on gotest.tools 2021-07-10 13:31:32 +10:00
pacoxu
669fb50136 upgrade staticcheck to v0.2.0 and update the static failure packages 2021-06-28 18:04:16 +08:00
Benjamin Elder
207f9e8b71 switch go-flow-levee to tagged version
this is actually a no-op source wise, but we want to prefer tagged versions
2021-06-15 19:37:20 -07:00
Michaël Lévesque-Dion
a94aa0ea9a Update version of go-flow-levee for verify-govet-levee check. 2021-06-08 12:02:46 -04:00
Benjamin Elder
45f910e79e update hack/tools README.md
bazel tools are no-more
2021-03-07 13:10:43 -08:00
Aditi Sharma
2ad5601a83 Add scripts to use klog/logcheck
Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>
2021-03-05 08:17:34 +00:00
Stephen Augustus
093967606b hack/tools: Update zeitgeist to v0.2.0 to drop import cycle
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-03-03 05:42:05 -05:00
Jordan Liggitt
ecef45df84 [go1.16] bump golang.org/x/... dependencies
hack/pin-dependency.sh golang.org/x/crypto latest
hack/pin-dependency.sh golang.org/x/net latest
hack/pin-dependency.sh golang.org/x/exp latest
hack/pin-dependency.sh golang.org/x/sys latest
hack/pin-dependency.sh golang.org/x/time latest
hack/pin-dependency.sh golang.org/x/tools latest

hack/lint-dependencies.sh
hack/pin-dependency.sh dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037
hack/pin-dependency.sh golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f
hack/pin-dependency.sh golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449

hack/lint-dependencies.sh

hack/update-internal-modules.sh
hack/update-vendor.sh

Co-authored-by: Stephen Augustus <foo@auggie.dev>
2021-03-02 00:38:01 -05:00
Stephen Augustus
3c2824e3db [go1.16] go.mod: update to go1.16
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-03-02 00:38:00 -05:00
Benjamin Elder
d9ef7cbe8c drop bazel related tools from hack/tools module 2021-02-28 15:17:29 -08:00
Stephen Augustus
5fb57eec1a generated: Run ./hack/update-internal-modules.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-02-22 08:48:04 -05:00
Stephen Augustus
68b9e70f3d hack/tools: Add zeitgeist@e06e277 for verifying external dependencies
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-02-22 08:30:57 -05:00
Davanum Srinivas
865fd2f04f
Use golangci-lint to find unused/dead code
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-02-19 12:12:02 -05:00
Davanum Srinivas
02eaf0f23d
remove references to golint in hack/tools
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-01-28 15:43:12 -05:00