Skip to content

Conversation

@camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Jul 20, 2025

Summary

  • Kubebuilder projects typically scaffold CRD-style APIs, and kube-api-linter exists to enforce those Kubernetes API conventions automatically for CRD authors rather than just core API teams.
  • This change wires kube-api-linter directly into the project template: the scaffold now creates a .custom-gcl.yml, adds Makefile and CI hooks, and enables the kubeapilinter module in .golangci.yml so every new operator starts with CRD-focused linting out of the box.
  • The optionalfields pointer policy defaults to WhenRequired, matching the kube-api-linter maintainers’ recommendation for CRDs and avoiding the stricter setting that targets core Kubernetes API types (kube-api-linter#128).

Closes: #4809

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 20, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch 3 times, most recently from 444bd36 to 6bda013 Compare July 20, 2025 19:57
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch 8 times, most recently from 85696c0 to 2f745c5 Compare July 25, 2025 10:36
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 15, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch from 2f745c5 to 6a5c28f Compare October 29, 2025 15:26
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 29, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch from 6a5c28f to 96e5382 Compare October 29, 2025 16:36
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 29, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch 2 times, most recently from ecd247e to 8fcd00e Compare October 29, 2025 17:55
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 29, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch 2 times, most recently from 787744d to 3ca5994 Compare November 15, 2025 06:07
@camilamacedo86 camilamacedo86 changed the title WIP: TEST KPA experimental install (go/v4): Add kubeapilinter to the default scaffold Nov 15, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 15, 2025
@camilamacedo86 camilamacedo86 changed the title (go/v4): Add kubeapilinter to the default scaffold ✨ (go/v4): Add kubeapilinter to the default scaffold Nov 15, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch from 3ca5994 to 08a0d45 Compare November 15, 2025 06:26
@camilamacedo86 camilamacedo86 changed the title ✨ (go/v4): Add kubeapilinter to the default scaffold ✨ (go/v4): scaffold kube-api-linter support in new projects Nov 15, 2025
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 15, 2025
Remove omitempty from JSON tags on nested struct fields such as metav1 ObjectMeta Status and metav1 ListMeta in API type scaffolds

The omitempty tag has no effect on nested structs in Go and triggers linter warnings

For Go version 1.24+ and later omitzero correctly handles nested structs and omits them when empty making omitempty redundant and misleading The optional markers already indicate optional fields for CRD schema generation

Updated JSON tags:

- metav1 ObjectMeta metadata omitempty omitzero becomes metadata omitzero
- Status fields status omitempty omitzero becomes status omitzero
- metav1 ListMeta metadata omitempty becomes metadata omitzero

This resolves linter warnings from gopls modernize analyzer and kube api linter while maintaining correct behavior for projects using Go 1.24+

Signed-off-by: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com>
@camilamacedo86 camilamacedo86 force-pushed the add-kpal-linter-otherway branch from 2baf23a to 93ca425 Compare November 15, 2025 06:57
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Nov 15, 2025
@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubebuilder-e2e-k8s-1-34-1 2f745c5 link true /test pull-kubebuilder-e2e-k8s-1-34-1
pull-kubebuilder-e2e-k8s-1-34-0 93ca425 link true /test pull-kubebuilder-e2e-k8s-1-34-0
pull-kubebuilder-e2e-k8s-1-33-0 93ca425 link true /test pull-kubebuilder-e2e-k8s-1-33-0

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Integrate kube-api-linter into Kubebuilder via golangci-lint

3 participants