ci: add kube-api-linter to linters - #4738
Open
pgmpofu wants to merge 1 commit into
Open
Conversation
|
|
Adds sigs.k8s.io/kube-api-linter (KAL) as a golangci-lint v2 module plugin and wires it into a new CI job that lints the API type definitions in ./apis against Kubernetes API conventions. Only the commentstart rule is enabled for now: it requires field godoc comments to start with the lowerCamelCase JSON field name, and its fixes are purely textual. Other KAL default rules (optionalorrequired, nonpointerstructs, arrayofstruct, nomaps) were evaluated but not enabled here, since applying them can suggest changing exported Go field types (e.g. value -> pointer with omitempty), which is a wire-compatibility decision that needs separate discussion, not something to fold into enabling a linter. Fixes the ~280 existing commentstart violations this surfaced across apis/, and regenerates CRDs and manifest_staging/ to match the updated doc comments. Fixes open-policy-agent#4219 Signed-off-by: Patience Mpofu <pgmpofu@gmail.com>
pgmpofu
force-pushed
the
ci/kube-api-linter
branch
from
August 16, 2026 08:19
5580e00 to
6aac2ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.custom-gcl.yml) and a newkube-api-lintCI job (.github/workflows/lint.yaml) that runs it against./apis.commentstartrule for now (.golangci-kube-api-linter.yaml): field godoc comments must start with the lowerCamelCase JSON field name. This rule's fixes are purely textual.commentstartviolations this surfaced acrossapis/, and regeneratesconfig/crd/bases/andmanifest_staging/to match.Why only
commentstart?KAL's other default rules (
optionalorrequired,nonpointerstructs,arrayofstruct,nomaps) can recommend changing exported Go field types (e.g.Driver string→Driver *stringwithomitempty) to resolve. I tried--fixwith the full default rule set first and it silently converted a requiredstringfield to a pointer — a wire-compatibility change that shouldn't ride along with enabling a linter. Those rules are left for a follow-up once there's a decision on how to apply them safely (see discussion on #4219).How it's wired
make lint-kube-apibuilds a customgolangci-lintbinary viagolangci-lint custom(needs localgo/git, hence not dockerized like the mainlinttarget) and runs it with--fixagainst./apis/....make lint-kube-apithengit diff --exit-code -- apis/to catch any unfixed/uncommitted violations, mirroring the existingcheck-manifestpattern.Test plan
make lint-kube-api— 0 issuesgolangci-lint run ./apis/...(existing config) — 0 issuesgo build ./...,go vet ./...,go test ./apis/...— passgofmt -l apis/— cleango.mod/go.sumandzz_generated.deepcopy.gofiles are unchanged (no type changes, comments only)controller-gen v0.21.0) andmanifest_staging/(kustomize v5.8.1+ helmify) match the doc-comment changes;deploy/andcharts/are left untouched since those are only promoted at release timeFixes #4219