100 Commits
Author SHA1 Message Date
Stephen Kitt bedc70cd7f Handle Go 1.27 go tool output format
go tool's output format changed with Go 1.27; it now shows

command (module)

This updates hack/update-tools.sh to handle the new format.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-30 16:05:56 +01:00
Stephen Kitt 706a0414b9 Bump to govulncheck 1.9.0
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-28 18:29:23 +01:00
Stephen Kitt 8ffdbc7bfc Track govulncheck as a tool
This ensures that new upstream versions are made visible using
standard Go tools; it also avoids repeated "go install"s of the same
version of the tool.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-28 18:29:23 +01:00
Stephen Kitt d2967bc861 Track zeitgeist as a tool
This ensures that new upstream versions are made visible using
standard Go tools; it also avoids repeated "go install"s of the same
version of the tool.

Since the version of zeitgeist is tracked in hack/tools/go.mod, this
also removes the version tracking in zeitgeist's own
build/dependencies.yaml, and updates the introductory comment there.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-28 18:28:42 +01:00
Stephen Kitt a42c2e29b9 Track whydeadcode as a tool
This ensures that upstream changes aren't applied without review; it
also avoids repeated "go install"s of the same version of the tool.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-28 15:04:54 +01:00
Stephen Kitt 8ef65551ac Bump golang/glog to v1.2.5 in hack/tools
govulncheck complains about publishing-verifier's use of glog:

The package pattern matched the following 2 root packages:
  k8s.io/kubernetes/hack/tools/publishing-verifier
  k8s.io/kubernetes/hack/tools/traceparse
Govulncheck scanned the following 6 modules and the go1.27.3 standard library:
  k8s.io/kubernetes/hack/tools
  github.com/golang/glog@v1.2.2
  golang.org/x/exp@v0.0.0-20260212183809-81e46e3db34a
  golang.org/x/mod@v0.41.0
  gopkg.in/yaml.v2@v2.4.0
  k8s.io/publishing-bot@v0.5.0

=== Symbol Results ===

Vulnerability #1: GO-2025-3372
    Vulnerability when creating log files in github.com/golang/glog
  More info: https://pkg.go.dev/vuln/GO-2025-3372
  Module: github.com/golang/glog
    Found in: github.com/golang/glog@v1.2.2
    Fixed in: github.com/golang/glog@v1.2.4
    Example traces found:
      #1: publishing-verifier/publishing-verifier.go:167:32: publishing.verifyPublishingBotRules calls config.LoadRules, which calls glog.Infof

=== Package Results ===

No other vulnerabilities found.

=== Module Results ===

No other vulnerabilities found.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-27 16:02:21 +01:00
Stephen Kitt 657a553aae Bump grpc to 1.85.0
This gets rid of a number of unwanted dependencies and updates x/net
too.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-27 10:59:54 +01:00
Stephen Kitt 5e5c837b67 Bump golangci-lint to v2.15.0
This doesn't raise any new issues on existing code.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-16 14:48:36 +02:00
Stephen Kitt 0180ae4efd Bump otel to v1.47.0
See
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.47.0
and
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.47.0
for details.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-10-07 16:33:41 +02:00
Stephen Kitt 15d15618a9 Bump to otel semconv v1.43.0
This allows v1.41.0 to be dropped from the tree entirely. v1.37.0 is
still present because otel references it for backwards-compatibility;
v1.40.0 is still present for etcd.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-29 13:47:32 +02:00
Stephen Kitt 759b65f1e3 Finish bumping otel to v1.46.0 and contrib to v0.71.0
See
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.45.0
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.46.0
and
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.45.0
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.46.0
for details.

otlptracegrpc is held back to v1.45.0 to avoid pulling in the latest
grpc-gateway and its swagger dependencies.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-29 13:47:22 +02:00
Stephen Kitt 892c8a4af5 Bump golangci-lint to v2.14.0, fix remaining %d issues
%d doesn't dereference pointers, so pointers are logged as such rather
than showing the value they point to. golangci-lint v2.14.0 now flags
this.

Most of these are obvious and safe because the pointer is dereferenced
before the log. flowcontrol/format/formatting.go is slightly more
involved, and formatting_test.go is added to illustrate the problem.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-28 14:34:03 +02:00
Stephen Kitt 6168af577d Bump to peterbourgon/diskv to v3.0.1
This is now a proper Go module; its dependency on google/btree is thus
apparent in unwanted-dependencies.json.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-28 11:56:27 +02:00
Stephen Kitt 3eb262aae9 Regenerate protobuf
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-22 01:20:16 +02:00
Stephen Kitt a3ff4c36f9 Bump google.golang.org/protobuf/cmd/protoc-gen-go
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-22 01:20:16 +02:00
Stephen Kitt 9576f619bb Bump golang.org/x/mod/modfile
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-22 01:20:16 +02:00
Stephen Kitt e6388004d3 Regenerate mocks
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-22 01:20:13 +02:00
Stephen Kitt ecda700ab9 Bump github.com/vektra/mockery/v3
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-22 01:10:25 +02:00
Stephen Kitt 776458e825 Drop container-storage-interface replaces
Two modules replace github.com/container-storage-interface/spec with
github.com/gnufied/spec v1.7.1-0.20260718120346-8e06851c4133, but now
that we use v1.13.0 of the spec, all the changes in the fork are
included. Since the replacement no longer seems necessary or useful,
this removes it.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-09 11:26:42 +02:00
Stephen Kitt ce5d4e30d5 Linting: drop obsolete "unused" exclusion
https://github.com/dominikh/go-tools/issues/1294 has been fixed, and
the excluded unused linter no longer flags
staging/src/k8s.io/client-go/util/workqueue/metrics.go; this removes
the exclusion.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-04 17:47:23 +02:00
Stephen Kitt 2df8df5954 Linting: enable waitgroupgo hint
Now that all supported branches are on Go 1.25+, we can enable the
waitgroupgo hint to encourage the use of waitgroup.Go instead of
waitgroup.Add/waitgrou.Done in new code.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-04 17:27:57 +02:00
Stephen Kitt 801001fb1b Bump container-storage-interface/spec to 1.13.0
... instead of the snapshot we currently depend on.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-01 17:10:33 +02:00
Stephen Kitt 5e6ecd6e44 hostpath: use tests with real files where possible
The setup and teardown functions intended for TestOSFileTypeChecker
suggest that it was intended to use real files where possible, but it
doesn't (or no longer does). This reworks the test function to use a
temporary directory and real files for all appropriate tests (based on
directories and files), and adds scenarios to cover the various code
paths in the checkType().

The resulting coverage includes all the code covered by
TestHostPathTypeCheckerInternal, so the latter can be dropped, which
allows checkType() to be simplified and the whole hostPathTypeChecker
interface and implementations to be dropped. Type checks all end up
comparing strings returned by HostUtils, so the IsDir(), IsFile()
etc. functions are also dropped in favour of direct type comparisons.

Overall hostpath test coverage increases from 65.8% to 68.1%, on fewer
lines of code.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-09-01 16:13:30 +02:00
Stephen Kitt e5dd45fd11 Drop k8s.io/utils/integer
The package is entirely deprecated, has a single user in k/k, with a
trivial replacement. This drops it and prevents its re-introduction.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-07-22 09:59:24 +02:00
Stephen Kitt 2d407830bd Bump to otel semconv v0.41.0
This aligns with the version used in otel v1.44.0 and otel contrib
v0.69.0.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-06-12 11:11:32 +02:00
Stephen Kitt defb4c53cd Bump otel contrib to v0.69.0
The main otel dependencies were bumped to v1.44.0; this aligns otel
contrib. See
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.44.0
for details.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-06-12 10:57:09 +02:00
Stephen Kitt 8f971144d0 Bump cadvisor to 0.57.0
This adds container creation timestamps.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-19 11:42:44 +02:00
Stephen Kitt b5ca9696ea Bump gotest.tools/gotestsum
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt 583376ca2a Bump google.golang.org/grpc/cmd/protoc-gen-go-grpc
This produces more readable raw descriptions.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt 1d193ca8ff Bump golang.org/x/mod/modfile
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt e223a05ec7 Bump github.com/vektra/mockery/v3
mockery ignores auto-generated code by default, so this requires a
couple of configuration changes.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt b7d0bea934 Bump github.com/jcchavezs/porto/cmd/porto
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt 7f5209efd2 Bump github.com/golangci/misspell
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt 8be5e8aac7 Bump github.com/cespare/prettybench
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:38 +02:00
Stephen Kitt 0d70476951 Bump github.com/aojea/sloppy-netparser
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:37 +02:00
Stephen Kitt 3789a3c639 Add a tool bumping script
This simplifies bumping the tool dependencies.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-12 11:55:37 +02:00
Stephen Kitt a43aad2e83 tools: drop staticcheck
A newer version of staticcheck is available through golangci-lint, and
that is what the project is using. The direct dependency in tools is
unnecessary, this removes that.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-11 09:28:41 +02:00
Stephen Kitt edf0df348c Bump go.yaml.in/yaml/v2 to 2.4.4
This only changes tests to drop gopkg.in/check.v1, which helps our
dependency tree a little.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-05-06 18:24:52 +02:00
Stephen Kitt 535e7460b8 Hard-code the otel http.target attribute
The dependency on semconv v1.17.0 is only used for its definition of
the http.target attribute; since that definition is used for a
workaround, and the attribute has been removed in later versions of
semconv (and is unlikely to come back), we might as well define it
ourselves and avoid the dependency entirely.

Vendored files will be removed once etcd upgrades its semconv
dependency.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-04-24 11:47:42 +02:00
Stephen Kitt e3c7e4e240 Bump otel semconv v1.12.0 to v1.40.0
This aligns with other uses and allows v1.12.0 to be dropped.

Remaining users of older semconv versions (v1.17.0) use http.target
which is no longer defined after v1.25.0.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-04-24 11:08:57 +02:00
Stephen Kitt 1a63916abe Bump otel to 1.43.0 and contrib to 0.68.0
See
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.41.0
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.42.0
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.43.0
and
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.41.0
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.42.0
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.43.0
for details.

otelgrpc no longer produces "messages" span events so these are
removed from the tracing test.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-04-23 14:35:21 +02:00
Stephen Kitt 3d1e90f95a Bump to golangci-lint 2.9.0
bloop was disabled because of its impact on small benchmarks (see
https://cs.opensource.google/go/x/tools/+/267fc6b81a168aa829f97c9209c2cacb503a56f2
for details), this removes it from the disabled entries.

stringscut was introduced in x/tools 0.40.0 and is disabled for
existing code.

ginkgolinter's Success matcher check doesn't know about TContext, so
it's disabled for k/k.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-02-16 15:45:22 +01:00
Stephen Kitt d42d1e3d1f Deprecate obsolete slice utility functions
... and update users to use standard library functions.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-02-16 10:04:33 +01:00
Stephen Kitt af5317bb88 Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-01-21 14:06:32 +01:00
Stephen Kitt 08b81b94f4 Align IsWatchListSemanticsUnSupported comment
The comment no longer matches the function name, this fixes that.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-01-21 13:55:11 +01:00
Stephen Kitt 3653ae2b9a Replace armon/circbuf with k8s.io/utils/buffer
This uses the new generic fixed ring implementation in k8s.io/utils.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-12-19 09:59:41 +01:00
Stephen Kitt 55c337637e Enforce Golang a, b = b, a swaps
This eliminates the last two remaining three-step value swaps (t =
a; a = b; b = t instead of a, b = b, a) and enables linting to prevent
new ones being added in future.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-11-13 06:38:23 -05:00
Stephen Kitt 1e2817d589 Avoid no-change lambdas
This replaces functions that wrap another function with no change with
a direct reference to the wrapped function.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-10-23 09:46:15 +02:00
Stephen Kitt 5bfc9aba9f Disable unwanted gocritic checks instead of filtering them
The golangci-lint docs indicate that, for gocritic, disabled-checks
and enabled-checks can't be combined. That is however not accurate;
enabled-checks adds checks, disabled-checks disables them, in that
order. If disable-all isn't set, then the setup starts with the checks
enabled by default, adds any additional checks specified in
enabled-checks, and removes checks specified in disabled-checks.

This means that instead of filtering unwanted checks, we can disable
them entirely. This makes the set of disabled checks easier to read,
and perhaps easier to clean up in future.

For singleCaseSwitch and wrapperFunc, we only want to ignore specific
instances, so this is still done by filtering.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-10-22 15:00:53 +02: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
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
Stephen Kitt c35d5473dd Remove the otel semantics override
With the bump to otelhttp 0.61, this is no longer necessary.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-08-28 09:23:06 +02:00
Stephen Kitt 684473af62 Bump cadvisor to 0.53
This brings a few fixes, drops github.com/pkg/errors (as a direct
dependency), and bumps many transitive dependencies. The
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp bump to
v0.61.0 breaks "k8s.io/kubernetes/test/integration/apiserver: tracing"
consistently, so it's held back for now.

github.com/containerd/containerd/api pulls in gopkg.in/yaml.v3 so that
needs to be added to the exceptions in unwanted-dependencies.json.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-08-28 09:20:21 +02:00
Stephen Kitt 2ca4ffe653 Add evanphx/json-patch/v5 to unwanted dependencies
This comes up periodically; bumping to v5 introduces issues with
replace operations in JSON patches. k/k relies on non-RFC-compliant
operations which v5 no longer allows.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-06-24 09:18:04 -04:00
Stephen Kitt d1bddfd779 Forbid github.com/pkg/errors in k/k
kubeadm has replaced pkg/errors with an internal implementation, which
means that pkg/errors can be marked as unwanted (once a final
straggler is replaced).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-06-05 18:03:56 +03:00
Stephen Kitt a6e2268994 Ensure github.com/pkg/errors is used only in kubeadm
Now that all other uses have been removed, this configures depguard to
ensure that new ones aren't added outside kubeadm.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-06-02 14:29:38 +02:00
Stephen Kitt 545fbc99c2 test: drop dependency on github.com/pkg/errors
The package is unmaintained, and the tests don't rely on the
functionality it provides on top of Golang errors (stack traces).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-06-02 11:27:09 +02:00
Stephen Kitt 1310fc027a kubelet: drop dependency on github.com/pkg/errors
The package is unmaintained, and kubelet doesn't appear to rely on the
functionality it provides on top of Golang errors (stack traces).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-05-26 16:41:38 +02:00
Stephen Kitt 54b2fad033 kubectl: drop dependency on github.com/pkg/errors
The package is unmaintained, and kubectl doesn't rely on the
functionality it provides on top of Golang errors (stack traces).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-05-26 11:28:24 +02:00
Stephen Kitt ee94ba913a Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-05-14 16:51:43 +02:00
Stephen Kitt 4eb9fb21b6 applyconfig-gen: handle non-pointer embedded members
Check that Elem is non-nil before dereferencing it. Also handle
non-empty names for named non-pointer embedded members.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-05-14 16:51:43 +02:00
Stephen Kitt c374ab8118 Add a breaking example for applyconfig-gen
This is based on the reproducer for
https://github.com/kubernetes/kubernetes/issues/131533.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-05-14 16:51:43 +02:00
Stephen Kitt 3d53bfec09 Typo fix: watchActcion
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-04-14 17:19:50 +02:00
Stephen Kitt 4f33b74a35 Use Go 1.24 os.Root instead of filepath-securejoin
All the features of securejoin used in k/k can be replaced by
equivalents in Go 1.24's new os.Root() feature.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-04-10 09:25:08 +02:00
Stephen Kitt 3986472b3c Revert to go-difflib and go-spew releases
The last dependency pulling in the tips of go-difflib and go-spew has
reverted to the last release of both projects, so k/k can revert to
the releases too. As can be seen from the contents of vendor, this
doesn't result in any actual change in the code.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-01-15 09:07:27 +01:00
Stephen Kitt efdb735750 kubeadm: fix idempotency retain, address deprecation
CreateOrRetain is supposed to operate on an object name which isn't
necessarily the given object's name (for use in migrations), this
restores that feature.

Replace all uses of deprecated functions with their generic variants.

Providing the context externally isn't useful right now, drop it from
the new functions and use context.Background() where needed.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-12-19 14:29:09 +01:00
Stephen Kitt db4c509e71 kubeadm: generalise CreateOrUpdate etc.
This uses generics to generalise the various CreateOrUpdate,
CreateOrRetain etc. functions. Where appropriate, the context is added
as an initial argument to the new functions.

ConfigMapMutator isn't used anywhere else, so it's dropped in favour
of the private objectMutator added in this commit.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-12-19 09:19:29 +01:00
Stephen Kitt 68ab918df7 Bump filepath-securejoin to 0.3.5
This release fixes a race in MkdirAll; the latter isn't currently used
in k/k, but it seems safer to upgrade to avoid issues if it starts
being used.

The latest version is 0.3.6 but that only reduces the Go requirements,
which isn't relevant for k/k and adds a couple hundred lines of code.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-12-17 19:46:03 +01:00
Stephen Kitt 3d069b2a8a Add myself to client-go reviewers
Given the ongoing work on generifying client-go, it might make sense
for me to be a reviewer (at least to keep better track of changes
being made before they go in).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-11-11 15:03:14 -07:00
Stephen Kitt 736e5560ba Align fake client-go clients with the main interface
"Real" clients use objectWithMeta to enforce support for meta.Object;
strictly speaking, fakes don't need this, but it's best to align them
with the real clients to ensure that fakes don't end up allowing types
that can't be used with the real clients.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-11-08 10:44:22 +01:00
Stephen Kitt be03bcf324 Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-11-08 09:48:59 +01:00
Stephen Kitt b0ce65df9b Generify fake clientsets
This adds a generic implementation of a fake clientset, and uses it to
replace the template code in generated fake clientsets for the default
methods. The templates are preserved as-is (or as close as they can
be) for use in extensions, whether for resources or subresources.

Fake clientsets with no extensions are reduced to their main getter,
their specific struct, and their constructor. All method
implementations are provided by the generic implementation. The
dedicated struct is preserved to allow extensions and expansions to be
defined where necessary.

Instead of handling the variants (with/without list, apply) with a
complex sequence of if statements, build up an index into an array
containing the various declarations.

Similarly, instead of calling different action constructors for
namespaced and non-namespaced clientsets, assume the current behaviour
of non-namespaced action creation (equivalent to creating a namespaced
action with an empty namespace) and document that assumption in the
action implementation.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-11-08 09:33:28 +01:00
Stephen Kitt 16817e8f4f kubelet: use new securejoin API
Using securejoin.SecureJoin() ensures that paths are bound within a
given root, but it doesn't protect from changes happening between the
construction of the path and its use. securejoin 0.3 introduces a new
Linux-specific API which avoids this by making rooted open operations
explicit; this migrates kubelet's log retrieval to use that.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-11-05 13:58:29 +01:00
Stephen Kitt 7918e9f0cb Add a unit test for heuristicsCopyFileLogs
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-23 11:58:52 +02:00
Stephen Kitt 7b730fcd73 Use ptr.To instead of a specific pointer function
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-23 11:58:52 +02:00
Stephen Kitt 9f2a02a723 kubelet: validate service names with slashes
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-23 11:58:52 +02:00
Stephen Kitt dbfab994bf kubelet: explicit variable names in Test_validateServices
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-23 11:58:52 +02:00
Stephen Kitt 6c5a528727 October 2024 golang.org/x bump
Nothing major here, but nothing liable to cause pain to downstreams
either.

* https://github.com/golang/crypto/compare/v0.26.0...v0.28.0 (there’s
  a SHA3 fix there but it’s only relevant for 32-bit platforms)
* https://github.com/golang/net/compare/v0.28.0...v0.30.0 (mostly
  http2; route address parsing fix on Darwin)
* https://github.com/golang/oauth2/compare/v0.21.0...v0.23.0 (Google
  license fix)
* https://github.com/golang/sys/compare/v0.23.0...v0.26.0 (faster
  getrandom() on Linux through the vDSO; improved RISC-V support)
* https://github.com/golang/term/compare/v0.23.0...v0.25.0
* https://github.com/golang/time/compare/v0.3.0...v0.7.0 (0-limit
  handling fix in x/time/rate; Google license fix)
* https://github.com/golang/tools/compare/v0.24.0...v0.26.0

This doesn’t include golang.org/x/exp; that doesn’t have any relevant
changes. There’s an apidiff fix but we always pull in the latest
apidiff anyway.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-11 10:22:13 +02:00
Stephen Kitt f1fa4086b3 Use sigs.k8s.io/yaml instead of gopkg.in/yaml
Since we have a Kubernetes-specific fork of go-yaml, use that
consistently throughout the project. This doesn't eliminate the
dependencies on gopkg.in/yaml, which are still used indirectly; but it
ensures that the whole project benefits from fixes or changes to
sigs.k8s.io/yaml.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-07 15:32:00 +02:00
Stephen Kitt aca3214a70 applyconfiguration-gen: drop yamlUnmarshal
It's unused.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-07 14:50:24 +02:00
Stephen Kitt 4531c6de76 client-go: remove obsolete auth plugins from examples
The azure and gcp plugins no longer do anything other than point to
the corresponding external credential plugins. Client code should no
longer try to load them, so they should be removed from the examples.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-10-03 11:08:52 +02:00
Stephen Kitt be0cd199d1 hack verify.sh: clean up "base"
This is a follow-up for commit beb51e1 ("make verify: run checks in
all module hack directories"). Checking only modules known to go ends
up ignoring modules which aren't dependencies, such as
./staging/src/k8s.io/code-generator/examples/hack; but the checks
should be run there too. So this finds modules by looking for go.mod
files.

Use PWD in run-checks to record failing verification scripts instead
of a hidden dependency on an externally-set variable.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-30 18:12:39 +02:00
Stephen Kitt 3124a13587 hack: configure Go environments where necessary
These scripts rely on the system's default go; this changes that using
kube::golang::setup_env so that the appropriate go is used when the
system's isn't sufficient.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-26 23:32:33 +02:00
Stephen Kitt beb51e1759 make verify: run checks in all module hack directories
This ensures that all verification scripts are run throughout the
repository.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-26 08:46:04 +02:00
Stephen Kitt 71c77414d4 Fix the path to code-generator in example update-codegen.sh
It seems this was copied from the main apiextensions-apiserver hack
directory without adjusting.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 23:30:45 +02:00
Stephen Kitt b5e294414a codegen: ignore .gitignore when diffing examples
The examples directory has a .gitignore file to ignore go.work.sum;
this isn't reproduced by codegen and fails the diff.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 23:30:40 +02:00
Stephen Kitt 13dfa4cbf5 Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 07:59:49 +02:00
Stephen Kitt 7313fec892 client-go: add missing template functions and types
Now that imports aren't automatically added, the client-go generator
produces broken code for extensions since it references a few
functions and types directly without declaring them properly
(klog.Warningf, time.Duration, time.Second).

The generated code also references c.client and c.ns which are no
longer accessible following the generic refactor.

This fixes both issues by adding missing template functions and types,
and going through the appropriate getters.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 07:59:40 +02:00
Stephen Kitt 06f072b009 Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 07:58:39 +02:00
Stephen Kitt b882213f8f Add a missing PatchOptions declaration for extensions
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 07:58:38 +02:00
Stephen Kitt acb1b364b8 Add an example with all possible extensions
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-25 07:58:33 +02:00
Stephen Kitt ff3e9ea79f pkg/api(s): drop pointer wrapper functions
The new k8s.io/utils/ptr package provides generic wrapper functions,
which can be used instead of type-specific pointer wrapper functions.
This replaces the latter with the former, and migrates other uses of
the deprecated pointer package to ptr in affacted files.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-23 23:00:34 +02:00
Stephen Kitt 4873de59e7 codegen: get rid of adjustTemplate
This adds the expected verb name to the template map, and uses that in
the template instead of replacing the verb name in the template before
processing.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-19 09:59:56 +02:00
Stephen Kitt 8a8238ba7f Drop references to auth-path and kubernetes_auth
These are long gone, removed in 2016:
* AuthPath removal: https://github.com/kubernetes/kubernetes/pull/29216
* Flag removal: https://github.com/kubernetes/kubernetes/pull/40048

This removes the remnants from clientcmd, mostly in the comments
describing how the configuration is loaded.

Since getServerIdentificationPartialConfig can no longer fail (it
copies fields from one struct to another), this drops the error
return, along with the error handling in the caller.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-10 17:45:45 +02:00
Stephen Kitt 6a11b61066 Only allow importing gengo/v2
The old gengo shouldn't be used any longer.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-09-03 17:55:05 +02:00
Stephen Kitt 689d6ef7a3 Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-08-30 17:11:03 +02:00
Stephen Kitt 68bad250b6 applyconfiguration-gen: handle conflicting members
With embedded structs, objects can end up with conflicting members.
These aren't ambiguous in Go, but applyconfiguration-gen's generated
functions ignore this possibility and produce ambiguous member
accesses and duplicate methods.

This resolves the problem by qualifying embedded member accesses with
their types when appropriate, and by memoizing generated function
names to avoid duplicates. When conflicting members are encountered,
functions are generated for the first one; this is assumed to produce
correct results.

For applyconfiguration-gen, a more correct approach would be to only
generate With... and Get... functions for the specific members the
generator is interested in; but that would be a breaking change for
any client code relying on the other With... functions.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-08-30 16:12:46 +02:00
Stephen Kitt 63439abb40 Add an example of conflicting members in apply configurations
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-08-30 16:12:46 +02:00
Stephen Kitt f4ddb44c36 Handle all mock header generation with mockery
mockery is set up to generate headers in all the mocks it produces, so
the separate header generation in update-mocks.sh is no longer useful
(and leads to duplicate headers in three cases). This removes the
relevant parts of the shell script.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-08-05 11:19:37 +02:00
Stephen Kitt 61aefc609f client-gen: use template function declarations for gentype
Instead of hard-coding gentype in the templates, use template function
declarations; this ensures that the package is correctly imported.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-07-05 14:27:41 +02:00