Add kube-api-linter module - #541
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| ## Verify all APIs using Kube API Linter | ||
| ## @category [shared] Generate/ Verify | ||
| verify-kube-api-lint: | $(NEEDS_GO) $(NEEDS_GOLANGCI-LINT-KUBE) $(bin_dir)/scratch | ||
| @find . -name go.mod -not \( -path "./$(bin_dir)/*" -or -path "./make/_shared/*" \) \ |
There was a problem hiding this comment.
Do we really need to find/loop here? The API types will typically reside in one Go module.
There was a problem hiding this comment.
Done in 9640e26 — the loop is gone, the linter now runs once in the repository root. See #541 (comment) for the full summary.
with claude fable-5
| ## Fix all APIs using Kube API Linter | ||
| ## @category [shared] Generate/ Verify | ||
| fix-kube-api-lint: | $(NEEDS_GO) $(NEEDS_GOLANGCI-LINT-KUBE) $(bin_dir)/scratch | ||
| @find . -name go.mod -not \( -path "./$(bin_dir)/*" -or -path "./make/_shared/*" \) \ |
There was a problem hiding this comment.
Same as above, to reduce complexity.
There was a problem hiding this comment.
Done in 9640e26 — the loop is gone, the linter now runs once in the repository root. See #541 (comment) for the full summary.
with claude fable-5
| golangci_lint_version := v2.8.0 | ||
| # https://pkg.go.dev/sigs.k8s.io/kube-api-linter?tab=versions | ||
| # renovate: datasource=go packageName=sigs.k8s.io/kube-api-linter | ||
| golangci_lint_kube_version := v0.0.0-20260114104534-18147eee9c49 |
There was a problem hiding this comment.
Wouldn't kube_api_linter_version be a better name for this variable? (And the same for similar/deduced variables)
There was a problem hiding this comment.
Done in 9640e26 — renamed to kube_api_linter_version and renamed the tool itself to kube-api-linter, so the deduced variables follow (KUBE-API-LINTER_VERSION, NEEDS_KUBE-API-LINTER, …). See #541 (comment) for the full summary.
with claude fable-5
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
- Rename the tool to kube-api-linter and the variables to kube_api_linter_* to match the module name. - Run the linter once in the repository root instead of looping over every Go module; API types typically live in a single module. - Fail early if kube_api_linter_config is not set, matching the go module's golangci_lint_config guard. - Generate .custom-gcl.yaml with printf instead of a yq pipeline, dropping the yq dependency from the build recipe, and avoid eval clobbering the global golangci_lint_version variable. - Bump sigs.k8s.io/kube-api-linter to the latest snapshot, tested against golangci-lint v2.13.0. - Add the module to the e2e test project so CI builds the custom binary and runs verify-kube-api-lint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Richard Wall <richard@the-moon.net>
7b621f4 to
9640e26
Compare
|
Rebased onto main and pushed 9640e26 addressing @erikgb's review:
Tested locally: the custom binary builds with golangci-lint v2.13.0, with claude fable-5 |
Adds a
kube-api-lintermakefile module for linting Kubernetes API types with sigs.k8s.io/kube-api-linter.How it works
toolsmodule gains akube-api-lintertool: a custom golangci-lint binary with the kube-api-linter plugin compiled in, built withgolangci-lint customfrom a generated.custom-gcl.yaml. Its version stamp combines the golangci-lint and plugin versions, and both are managed by Renovate.kube-api-lintermodule providesverify-kube-api-lint(wired intomake verify) andfix-kube-api-lint. The linter runs once in the repository root, using the config file named by the requiredkube_api_linter_configvariable.Usage
Klone the
kube-api-lintermodule, then set:kube_api_linter_config := .golangci.kube-api-linter.yamlwith a golangci-lint v2 config enabling the
kubeapilintercustom linter (see the e2e test-project for a minimal example).Testing
The e2e test-project now includes the module, so CI builds the custom binary and runs
verify-kube-api-linton Linux and macOS. Also verified locally that the linter fails the build on a struct with a non-pointer+optionalfield.with claude fable-5