Skip to content

ci: add kube-api-linter to linters - #4738

Open
pgmpofu wants to merge 1 commit into
open-policy-agent:masterfrom
pgmpofu:ci/kube-api-linter
Open

ci: add kube-api-linter to linters#4738
pgmpofu wants to merge 1 commit into
open-policy-agent:masterfrom
pgmpofu:ci/kube-api-linter

Conversation

@pgmpofu

@pgmpofu pgmpofu commented Aug 16, 2026

Copy link
Copy Markdown

Summary

  • Adds kube-api-linter (KAL) as a golangci-lint v2 module plugin (.custom-gcl.yml) and a new kube-api-lint CI job (.github/workflows/lint.yaml) that runs it against ./apis.
  • Enables only the commentstart rule 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.
  • Fixes the ~280 existing commentstart violations this surfaced across apis/, and regenerates config/crd/bases/ and manifest_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 stringDriver *string with omitempty) to resolve. I tried --fix with the full default rule set first and it silently converted a required string field 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-api builds a custom golangci-lint binary via golangci-lint custom (needs local go/git, hence not dockerized like the main lint target) and runs it with --fix against ./apis/....
  • CI runs make lint-kube-api then git diff --exit-code -- apis/ to catch any unfixed/uncommitted violations, mirroring the existing check-manifest pattern.

Test plan

  • make lint-kube-api — 0 issues
  • golangci-lint run ./apis/... (existing config) — 0 issues
  • go build ./..., go vet ./..., go test ./apis/... — pass
  • gofmt -l apis/ — clean
  • Verified go.mod/go.sum and zz_generated.deepcopy.go files are unchanged (no type changes, comments only)
  • Regenerated CRDs (controller-gen v0.21.0) and manifest_staging/ (kustomize v5.8.1 + helmify) match the doc-comment changes; deploy/ and charts/ are left untouched since those are only promoted at release time

Fixes #4219

@pgmpofu
pgmpofu requested a review from a team as a code owner August 16, 2026 07:01
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 16, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: pgmpofu / name: Patience Mpofu (6aac2ac)

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
pgmpofu force-pushed the ci/kube-api-linter branch from 5580e00 to 6aac2ac Compare August 16, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: add kube-api-linter to linters

1 participant