Skip to content

Commit 1d02795

Browse files
api: refactor MultiAdmin config to fix recursive nesting
Removes the `ComponentConfig` struct to prevent `CoreTemplate` from referencing other templates and to simplify the API structure. Changes: - Replaces `ComponentConfig` with a specialized `MultiAdminConfig` in `MultigresCluster`, enforcing "Spec OR TemplateRef" validation. - Updates `CoreTemplate` to use `StatelessSpec` directly for `MultiAdmin`, flattening the YAML structure (removing the `spec` nesting) and preventing recursive template references. - Deletes the unused `ComponentConfig` from `common_types.go`.
1 parent 691086d commit 1d02795

File tree

5 files changed

+708
-727
lines changed

5 files changed

+708
-727
lines changed

api/v1alpha1/common_types.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,6 @@ type StatelessSpec struct {
5656
PodLabels map[string]string `json:"podLabels,omitempty"`
5757
}
5858

59-
// ComponentConfig is a generic wrapper for components that support
60-
// inline spec OR template reference.
61-
// +kubebuilder:validation:XValidation:rule="has(self.spec) || has(self.templateRef)",message="must specify either 'spec' or 'templateRef'"
62-
// +kubebuilder:validation:XValidation:rule="!(has(self.spec) && has(self.templateRef))",message="cannot specify both 'spec' and 'templateRef'"
63-
type ComponentConfig struct {
64-
// Spec defines the inline configuration.
65-
// +optional
66-
Spec *StatelessSpec `json:"spec,omitempty"`
67-
68-
// TemplateRef refers to a CoreTemplate to load configuration from.
69-
// +optional
70-
// +kubebuilder:validation:MinLength=1
71-
// +kubebuilder:validation:MaxLength=63
72-
TemplateRef string `json:"templateRef,omitempty"`
73-
}
74-
7559
// StorageSpec defines the storage configuration.
7660
type StorageSpec struct {
7761
// Size of the persistent volume.

api/v1alpha1/coretemplate_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type CoreTemplateSpec struct {
3232

3333
// MultiAdmin configuration.
3434
// +optional
35-
MultiAdmin *ComponentConfig `json:"multiadmin,omitempty"`
35+
MultiAdmin *StatelessSpec `json:"multiadmin,omitempty"`
3636
}
3737

3838
// ============================================================================

api/v1alpha1/multigrescluster_types.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type MultigresClusterSpec struct {
4242

4343
// MultiAdmin defines the configuration for the MultiAdmin component.
4444
// +optional
45-
MultiAdmin ComponentConfig `json:"multiadmin,omitempty"`
45+
MultiAdmin MultiAdminConfig `json:"multiadmin,omitempty"`
4646

4747
// Cells defines the list of cells (failure domains) in the cluster.
4848
// +optional
@@ -121,6 +121,26 @@ type TemplateDefaults struct {
121121
ShardTemplate string `json:"shardTemplate,omitempty"`
122122
}
123123

124+
// ============================================================================
125+
// MultiAdmin Config Section Specs
126+
// ============================================================================
127+
128+
// MultiAdminConfig defines the configuration for MultiAdmin in the Cluster.
129+
// It allows either an inline spec OR a reference to a CoreTemplate.
130+
// +kubebuilder:validation:XValidation:rule="has(self.spec) || has(self.templateRef)",message="must specify either 'spec' or 'templateRef'"
131+
// +kubebuilder:validation:XValidation:rule="!(has(self.spec) && has(self.templateRef))",message="cannot specify both 'spec' and 'templateRef'"
132+
type MultiAdminConfig struct {
133+
// Spec defines the inline configuration.
134+
// +optional
135+
Spec *StatelessSpec `json:"spec,omitempty"`
136+
137+
// TemplateRef refers to a CoreTemplate to load configuration from.
138+
// +optional
139+
// +kubebuilder:validation:MinLength=1
140+
// +kubebuilder:validation:MaxLength=63
141+
TemplateRef string `json:"templateRef,omitempty"`
142+
}
143+
124144
// ============================================================================
125145
// Cell Config Section Specs
126146
// ============================================================================

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)