refactor: migrate Template field from value to pointer type #102
+33
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This PR addresses the
templatefield design issue discussed in KEP-8 (#70).Problem
KEP-8 introduces
templateRefandtemplateas logically mutually exclusive options. However, with the current value-type design:PodTemplateSpec{}serializes to invalid JSON that violates CRD schematemplateRef(bad UX)Solution
Migrate
Templatefrom value type to pointer type (Solution 2 from the discussion).Why pointer over placeholder approach:
nil= not set, avoiding placeholder code smellTiming:
Changes
API Layer
RoleSpec.Template:corev1.PodTemplateSpec→*corev1.PodTemplateSpec+optional(was+kubebuilder:validation:Required)templateno longer in required fieldsController Logic
nilTemplate gracefully with zero-value fallbackTest Updates
&templateorptr.To())Auto-generated
Breaking Change
For Go SDK Users
Before:
For YAML Users
No change required. YAML manifests remain compatible:
For KEP-8 templateRef mode (future PR):
Testing
Related
Relates to #70
This is the prerequisite API change. KEP-8 feature implementation (templateRef/templatePatch) will follow in a separate PR after community review.