refactor: migrate Template field from value to pointer type#102
Merged
Syspretor merged 1 commit intosgl-project:mainfrom Nov 20, 2025
Merged
Conversation
Breaking API change: RoleSpec.Template changes to pointer type. Changes: - API: Template corev1.PodTemplateSpec → *corev1.PodTemplateSpec - Mark field as +optional (was +kubebuilder:validation:Required) - Controller: Handle nil Template with zero-value fallback - Internal: Update patchPodTemplate to use pointer throughout - Tests: Update to use pointer initialization - Auto-generated: CRD manifests and DeepCopy code Breaking Change: - Go code must use &template or ptr.To(template) - YAML/JSON manifests remain compatible (template now optional)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
LikiosSedo
pushed a commit
to LikiosSedo/rbg
that referenced
this pull request
Nov 17, 2025
Apply pointer migration changes to KEP-8 branch: - Change RoleSpec.Template from value to pointer type (*corev1.PodTemplateSpec) - Update all test files to use pointer syntax - Update reconcilers to handle nil Template pointer - Update validation logic to work with pointer types - Regenerate CRD manifests and DeepCopy code This integrates the template pointer migration (sgl-project#102) with the KEP-8 RoleTemplate feature, allowing Template to be optional when using templateRef.
7c3af58 to
67e62e9
Compare
Collaborator
|
/gemini review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Syspretor
approved these changes
Nov 20, 2025
Collaborator
|
/lgtm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.