-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
Labels
lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.
Description
Bug: optionalfields incorrectly requires pointer for enum-like field with default
The optionalfields rule in kube-api-linter is flagging a field that should be valid:
// +optional
// +kubebuilder:default:=Allow
ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"`Error:
optionalfields: field ConcurrencyPolicy is optional and should be a pointer
However:
- The field has a default (
Allow) - It's not semantically optional (default is always injected)
- It's an enum-style string alias (not a struct or slice)
Upstream Kubernetes APIs (e.g. batch/v1) define similar fields without pointers.
Suggestion
The rule should not require a pointer if:
- The field is a basic or alias type (e.g.
string) - It has
+optionaland+kubebuilder:default - The tag includes
omitempty
This avoids unnecessary boilerplate and aligns with upstream standards.
Metadata
Metadata
Assignees
Labels
lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.