Skip to content

Commit

Permalink
feat: compatible shardingSpecs and instances for cluster (#7101)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei authored Apr 23, 2024
1 parent 6c2e37b commit f992c2a
Show file tree
Hide file tree
Showing 47 changed files with 2,442 additions and 5,870 deletions.
15 changes: 14 additions & 1 deletion apis/apps/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ type InstanceTemplate struct {
// Defines VolumeClaimTemplates to override.
// Add new or override existing volume claim templates.
// +optional
VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"`
VolumeClaimTemplates []ClusterComponentVolumeClaimTemplate `json:"volumeClaimTemplates,omitempty"`
}

// ClusterStatus defines the observed state of Cluster.
Expand Down Expand Up @@ -804,6 +804,10 @@ type ClusterComponentSpec struct {
// Any remaining replicas will be generated using the default template and will follow the default naming rules.
//
// +optional
// +patchMergeKey=name
// +patchStrategy=merge,retainKeys
// +listType=map
// +listMapKey=name
Instances []InstanceTemplate `json:"instances,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

// Specifies the names of instances to be transitioned to offline status.
Expand Down Expand Up @@ -1420,6 +1424,15 @@ func (r ClusterSpec) GetComponentByName(componentName string) *ClusterComponentS
return nil
}

func (r ClusterSpec) GetShardingByName(shardingName string) *ShardingSpec {
for _, v := range r.ShardingSpecs {
if v.Name == shardingName {
return &v
}
}
return nil
}

// GetComponentDefRefName gets the name of referenced component definition.
func (r ClusterSpec) GetComponentDefRefName(componentName string) string {
for _, component := range r.ComponentSpecs {
Expand Down
Loading

0 comments on commit f992c2a

Please sign in to comment.