Skip to content

Conversation

@moko-poi
Copy link

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR enables the KAL (Kube-API-Linter) optionalorrequired linter, which ensures that every field in API types is explicitly marked as either +optional or +required.

Changes made:

  • Enabled optionalorrequired linter in .golangci-kal.yml
  • Added +optional markers to fields with omitempty json tags
  • Added +required markers to fields without omitempty json tags
  • Fixed 1509 linter issues across 148 files

This improves API documentation clarity by making it explicit whether each field is required or optional, following Kubernetes API conventions. This helps API consumers better understand the contract of each field.

Which issue(s) this PR fixes:
Fixes #5491

Special notes for your reviewer:

The changes were made using a combination of automatic fixes (make lint-api-fix) and a custom Python script to handle the remaining cases. The script adds markers based on the presence of omitempty in json tags:

  • Fields with json:"...,omitempty"// +optional
  • Fields with json:"..." (no omitempty) → // +required

All changes are purely additive comments and do not affect runtime behavior. Tests pass successfully.

Checklist:

  • squashed commits
  • includes documentation (N/A - documentation is in code comments)
  • includes emoji in title
  • adds unit tests (N/A - existing tests validate the changes)
  • adds or updates e2e tests (N/A - no behavioral changes)

Release note:

Enabled optionalorrequired linter to improve API documentation clarity by explicitly marking all struct fields as +optional or +required

@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 18, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign dlipovetsky for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Nov 18, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 18, 2025
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 18, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @moko-poi. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2025
@moko-poi moko-poi force-pushed the enable_optionalorrequired_linter branch from fe06ced to bbd1f33 Compare November 22, 2025 02:49
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2025
@moko-poi moko-poi closed this Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[KAL] Enable optionalorrequired linter

2 participants