Skip to content

Commit e2755e7

Browse files
committed
clusters were migrated on clusterresource refs pattern
1 parent 660c5ab commit e2755e7

File tree

58 files changed

+1707
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1707
-272
lines changed

apis/clusterresources/v1beta1/clusterbackup_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727

2828
// ClusterBackupSpec defines the desired state of ClusterBackup
2929
type ClusterBackupSpec struct {
30-
ClusterID string `json:"clusterId,omitempty"`
3130
ClusterKind string `json:"clusterKind"`
3231
}
3332

apis/clusterresources/v1beta1/exclusionwindow_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
// ExclusionWindowSpec defines the desired state of ExclusionWindow
2727
type ExclusionWindowSpec struct {
28-
ClusterID string `json:"clusterId,omitempty"`
2928
DayOfWeek string `json:"dayOfWeek"`
3029
//+kubebuilder:validation:Minimum:=0
3130
//+kubebuilder:validation:Maximum:=23

apis/clusterresources/v1beta1/gcpvpcpeering_types.go

-8
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@ func init() {
8383
}
8484

8585
func (gcp *GCPVPCPeeringSpec) Validate() error {
86-
dataCentreIDMatched, err := regexp.Match(models.UUIDStringRegExp, []byte(gcp.DataCentreID))
87-
if err != nil {
88-
return err
89-
}
90-
if !dataCentreIDMatched {
91-
return fmt.Errorf("data centre ID is a UUID formated string. It must fit the pattern: %s", models.UUIDStringRegExp)
92-
}
93-
9486
for _, subnet := range gcp.PeerSubnets {
9587
peerSubnetMatched, err := regexp.Match(models.PeerSubnetsRegExp, []byte(subnet))
9688
if err != nil {

apis/clusterresources/v1beta1/gcpvpcpeering_webhook.go

-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ func (r *GCPVPCPeering) ValidateCreate() error {
6767
return fmt.Errorf("peer Project ID is empty")
6868
}
6969

70-
if r.Spec.DataCentreID == "" {
71-
return fmt.Errorf("dataCentre ID is empty")
72-
}
73-
7470
if r.Spec.PeerSubnets == nil {
7571
return fmt.Errorf("peer Subnets list is empty")
7672
}

apis/clusterresources/v1beta1/structs.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import (
2121
)
2222

2323
type VPCPeeringSpec struct {
24-
DataCentreID string `json:"cdcId,omitempty"`
25-
PeerSubnets []string `json:"peerSubnets"`
24+
PeerSubnets []string `json:"peerSubnets"`
2625
}
2726

2827
type PeeringStatus struct {
@@ -41,8 +40,7 @@ type PatchRequest struct {
4140
}
4241

4342
type FirewallRuleSpec struct {
44-
ClusterID string `json:"clusterId,omitempty"`
45-
Type string `json:"type"`
43+
Type string `json:"type"`
4644
}
4745

4846
type FirewallRuleStatus struct {

apis/clusters/v1beta1/cadence_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type CadenceSpec struct {
7373
PackagedProvisioning []*PackagedProvisioning `json:"packagedProvisioning,omitempty"`
7474
TargetPrimaryCadence []*TargetCadence `json:"targetPrimaryCadence,omitempty"`
7575
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
76+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
7677
}
7778

7879
type AWSArchival struct {

apis/clusters/v1beta1/cassandra_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type CassandraSpec struct {
6363
Spark []*Spark `json:"spark,omitempty"`
6464
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
6565
UserRefs References `json:"userRefs,omitempty"`
66+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
6667
//+kubebuilder:validate:MaxItems:=1
6768
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
6869
}
@@ -152,7 +153,6 @@ func (c *Cassandra) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.C
152153
Finalizers: []string{models.DeletionFinalizer},
153154
},
154155
Spec: clusterresourcesv1beta1.ClusterBackupSpec{
155-
ClusterID: c.Status.ID,
156156
ClusterKind: models.CassandraClusterKind,
157157
},
158158
}

apis/clusters/v1beta1/kafka_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type KafkaSpec struct {
8989
KarapaceSchemaRegistry []*KarapaceSchemaRegistry `json:"karapaceSchemaRegistry,omitempty"`
9090
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
9191
UserRefs References `json:"userRefs,omitempty"`
92+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
9293
Kraft []*Kraft `json:"kraft,omitempty"`
9394
}
9495

apis/clusters/v1beta1/kafkaconnect_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ type KafkaConnectSpec struct {
111111

112112
// CustomConnectors defines the location for custom connector storage and access info.
113113
CustomConnectors []*CustomConnectors `json:"customConnectors,omitempty"`
114+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
114115
}
115116

116117
// KafkaConnectStatus defines the observed state of KafkaConnect

apis/clusters/v1beta1/opensearch_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type OpenSearchSpec struct {
5454
AlertingPlugin bool `json:"alertingPlugin,omitempty"`
5555
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
5656
UserRefs References `json:"userRefs,omitempty"`
57+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
5758
//+kubuilder:validation:MaxItems:=1
5859
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
5960
//+kubuilder:validation:MaxItems:=1
@@ -584,7 +585,6 @@ func (os *OpenSearch) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1
584585
Finalizers: []string{models.DeletionFinalizer},
585586
},
586587
Spec: clusterresourcesv1beta1.ClusterBackupSpec{
587-
ClusterID: os.Status.ID,
588588
ClusterKind: models.OsClusterKind,
589589
},
590590
}

apis/clusters/v1beta1/postgresql_types.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,15 @@ type PgRestoreFrom struct {
7575
type PgSpec struct {
7676
PgRestoreFrom *PgRestoreFrom `json:"pgRestoreFrom,omitempty"`
7777
Cluster `json:",inline"`
78-
DataCentres []*PgDataCentre `json:"dataCentres,omitempty"`
79-
ClusterConfigurations map[string]string `json:"clusterConfigurations,omitempty"`
80-
SynchronousModeStrict bool `json:"synchronousModeStrict,omitempty"`
81-
UserRefs []*Reference `json:"userRefs,omitempty"`
78+
DataCentres []*PgDataCentre `json:"dataCentres,omitempty"`
79+
ClusterConfigurations map[string]string `json:"clusterConfigurations,omitempty"`
80+
SynchronousModeStrict bool `json:"synchronousModeStrict,omitempty"`
81+
UserRefs []*Reference `json:"userRefs,omitempty"`
8282
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
8383
//+kubebuilder:validate:MaxItems:=1
8484
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
8585
}
8686

87-
type ClusterResourceRefs struct {
88-
ClusterBackups []*NamespacedName `json:"clusterBackups,omitempty"`
89-
ClusterNetworkFirewallRules []*NamespacedName `json:"clusterNetworkFirewallRules,omitempty"`
90-
AWSVPCPeerings []*NamespacedName `json:"awsVPCPeerings,omitempty"`
91-
AWSSecurityGroupFirewallRules []*NamespacedName `json:"awsSecurityGroupFirewallRules,omitempty"`
92-
ExclusionWindows []*NamespacedName `json:"exclusionWindows,omitempty"`
93-
GCPVPCPeerings []*NamespacedName `json:"gcpVPCPeerings,omitempty"`
94-
AzureVNetPeerings []*NamespacedName `json:"azureVNetPeerings,omitempty"`
95-
}
96-
9787
// PgStatus defines the observed state of PostgreSQL
9888
type PgStatus struct {
9989
ClusterStatus `json:",inline"`

apis/clusters/v1beta1/redis_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ type RedisSpec struct {
6969
//+kubebuilder:validation:MaxItems:=2
7070
DataCentres []*RedisDataCentre `json:"dataCentres,omitempty"`
7171

72-
UserRefs References `json:"userRefs,omitempty"`
72+
UserRefs References `json:"userRefs,omitempty"`
73+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
7374
//+kubebuilder:validation:MaxItems:=1
7475
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
7576
}
@@ -143,7 +144,6 @@ func (r *Redis) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.Clust
143144
Finalizers: []string{models.DeletionFinalizer},
144145
},
145146
Spec: clusterresourcesv1beta1.ClusterBackupSpec{
146-
ClusterID: r.Status.ID,
147147
ClusterKind: models.RedisClusterKind,
148148
},
149149
}

apis/clusters/v1beta1/structs.go

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type DataCentre struct {
4545
}
4646

4747
type DataCentreStatus struct {
48+
Name string `json:"name,omitempty"`
4849
ID string `json:"id,omitempty"`
4950
Status string `json:"status,omitempty"`
5051
Nodes []*Node `json:"nodes,omitempty"`
@@ -558,6 +559,7 @@ func areClusteredMaintenanceEventStatusEqual(a, b *clusterresource.MaintenanceEv
558559

559560
func (cs *ClusterStatus) DCFromInstAPI(iDC models.DataCentre) *DataCentreStatus {
560561
return &DataCentreStatus{
562+
Name: iDC.Name,
561563
ID: iDC.ID,
562564
Status: iDC.Status,
563565
Nodes: cs.NodesFromInstAPI(iDC.Nodes),
@@ -713,6 +715,20 @@ func (cs *ClusterStatus) PrivateLinkStatusesEqual(iStatus *ClusterStatus) bool {
713715
return true
714716
}
715717

718+
type ClusterResourceRefs struct {
719+
ClusterBackups []*ClusterResourceRef `json:"clusterBackups,omitempty"`
720+
ClusterNetworkFirewallRules []*ClusterResourceRef `json:"clusterNetworkFirewallRules,omitempty"`
721+
AWSVPCPeerings []*ClusterResourceRef `json:"awsVPCPeerings,omitempty"`
722+
AWSSecurityGroupFirewallRules []*ClusterResourceRef `json:"awsSecurityGroupFirewallRules,omitempty"`
723+
ExclusionWindows []*ClusterResourceRef `json:"exclusionWindows,omitempty"`
724+
GCPVPCPeerings []*ClusterResourceRef `json:"gcpVPCPeerings,omitempty"`
725+
AzureVNetPeerings []*ClusterResourceRef `json:"azureVNetPeerings,omitempty"`
726+
}
727+
type ClusterResourceRef struct {
728+
Reference `json:",inline"`
729+
DataCentreName string `json:"dataCentreName,omitempty"`
730+
}
731+
716732
type Reference struct {
717733
Name string `json:"name"`
718734
Namespace string `json:"namespace"`

apis/clusters/v1beta1/zookeeper_types.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ type ZookeeperDataCentre struct {
3636

3737
// ZookeeperSpec defines the desired state of Zookeeper
3838
type ZookeeperSpec struct {
39-
Cluster `json:",inline"`
40-
DataCentres []*ZookeeperDataCentre `json:"dataCentres"`
39+
Cluster `json:",inline"`
40+
DataCentres []*ZookeeperDataCentre `json:"dataCentres"`
41+
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
4142
}
4243

4344
// ZookeeperStatus defines the observed state of Zookeeper

0 commit comments

Comments
 (0)