chore(linter): add new kube-api-linter and fix CRD lint issues #1985
chore(linter): add new kube-api-linter and fix CRD lint issues #1985dongjiang1989 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates Kubernetes API type documentation and linter configuration to satisfy newly enabled kubeapilinter checks in Go.
Changes:
- Enabled additional
kubeapilinterchecks (e.g.,jsontags,nomaps,notimestamp,nodurations) ingolangci-lintconfig. - Reworded many field doc comments to start with the JSON tag name (lowerCamel) rather than the Go field name.
- Added
//nolint:kubeapilintersuppressions for a few fields in deprecated / soon-to-change APIs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| go/api/v1alpha2/remotemcpserver_types.go | Adjusts CRD field docstrings and adds kubeapilinter suppressions for duration fields. |
| go/api/v1alpha2/modelproviderconfig_types.go | Updates field docstrings to match JSON tag names. |
| go/api/v1alpha2/modelconfig_types.go | Updates field docstrings to match JSON tag names across multiple config structs. |
| go/api/v1alpha2/common_types.go | Updates AllowedNamespaces field docstrings to match JSON tag names. |
| go/api/v1alpha2/agentharness_types.go | Updates many docstrings to match JSON tag names. |
| go/api/v1alpha2/agent_types.go | Updates many docstrings to match JSON tag names. |
| go/api/v1alpha1/toolserver_types.go | Adds kubeapilinter suppressions for deprecated API fields. |
| go/api/v1alpha1/modelconfig_types.go | Updates docstrings to match JSON tag names. |
| go/api/v1alpha1/agent_types.go | Updates A2AConfig docstring to match JSON tag name. |
| go/.golangci.yaml | Enables additional kubeapilinter checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c7fecf6 to
07c2061
Compare
|
@EItanya PTAL, thanks |
bee5af8 to
015b7b2
Compare
|
I think that it would be nice to move in this direction, but I'd prefer if we had a plan for doing so (especially around breaking changes) rather than just enabling linting and skipping checks on specific fields that would fail otherwise. It could be useful to see which of these checks are currently passing with our current CRDs and which require changes. |
Signed-off-by: dongjiang <dongjiang1989@126.com>
Signed-off-by: dongjiang <dongjiang1989@126.com>
Signed-off-by: dongjiang <dongjiang1989@126.com>
015b7b2 to
ece56f1
Compare
Thanks @iplay88keys Add #2026 for TODO tasks. |
Signed-off-by: dongjiang <dongjiang1989@126.com>
Signed-off-by: dongjiang <dongjiang1989@126.com>
Add the
kube-api-lintercustom golangci-lint plugin to enforce Kubernetes API conventions across CRD type definitions. The following sub-linters are now enabled:nodurations— disallowstime.Durationfields in API types (use string-based durations)noreferences— prevents use of pointer/reference types in API fieldsnotimestamp— disallowstime.Timefields in API typesjsontags— ensures JSON struct tags follow Go naming conventions (lowercase first letter)statusoptional— enforces// +optionalmarker on status subfieldsAll resulting lint violations across
v1alpha1andv1alpha2CRD types have been resolved. Most fixes involve lowercasing the first letter of JSON struct tags for compliance.