Commit d31b32b
committed
Fix kubebuilder optional/required markers for API fields
Add missing optional/required markers to resolve kube-api-linter errors
while preserving correct API semantics and discriminated union patterns.
Detailed Change Explanations:
1. api/v1/clustercatalog_types.go
Change: Added // +optional marker to ResolvedCatalogSource.Image field
Reason:
- This is a discriminated union field controlled by the Type field
- XValidation enforces: when Type == "Image", Image is required; otherwise forbidden
- Field is conditionally required, not always required
- Field may be nil during initial reconciliation
- Allows future extensibility
- Fixes kube-api-linter optionalorrequired error
2. api/v1/clusterextension_types.go
Change: Added // +optional marker and omitempty to PreflightConfig.CRDUpgradeSafety
Reason:
- Production code checks for nil
- Field is optional at the Go level
- omitempty follows Kubernetes conventions
- Fixes kube-api-linter optionalorrequired error
3. api/v1/clusterextensionrevision_types.go
Change: Added // +required marker to ClusterExtensionRevisionPhase.Objects
Reason:
- Field is a slice and must always be present
- Tests show empty slice is valid
- No omitempty by design
- Godoc confirms it is required
- Fixes kube-api-linter optionalorrequired error1 parent b0e0d65 commit d31b32b
File tree
3 files changed
+4
-1
lines changed- api/v1
3 files changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
249 | 250 | | |
250 | 251 | | |
251 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
| 409 | + | |
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
0 commit comments