Skip to content

Commit

Permalink
clusters were migrated on clusterresource refs pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
tengu-alt committed Nov 16, 2023
1 parent 3a74ba1 commit 181a49e
Show file tree
Hide file tree
Showing 57 changed files with 2,488 additions and 86 deletions.
1 change: 0 additions & 1 deletion apis/clusterresources/v1beta1/clusterbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

// ClusterBackupSpec defines the desired state of ClusterBackup
type ClusterBackupSpec struct {
ClusterID string `json:"clusterId,omitempty"`
ClusterKind string `json:"clusterKind"`
}

Expand Down
1 change: 0 additions & 1 deletion apis/clusterresources/v1beta1/exclusionwindow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

// ExclusionWindowSpec defines the desired state of ExclusionWindow
type ExclusionWindowSpec struct {
ClusterID string `json:"clusterId,omitempty"`
DayOfWeek string `json:"dayOfWeek"`
//+kubebuilder:validation:Minimum:=0
//+kubebuilder:validation:Maximum:=23
Expand Down
8 changes: 0 additions & 8 deletions apis/clusterresources/v1beta1/gcpvpcpeering_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ func init() {
}

func (gcp *GCPVPCPeeringSpec) Validate() error {
dataCentreIDMatched, err := regexp.Match(models.UUIDStringRegExp, []byte(gcp.DataCentreID))
if err != nil {
return err
}
if !dataCentreIDMatched {
return fmt.Errorf("data centre ID is a UUID formated string. It must fit the pattern: %s", models.UUIDStringRegExp)
}

for _, subnet := range gcp.PeerSubnets {
peerSubnetMatched, err := regexp.Match(models.PeerSubnetsRegExp, []byte(subnet))
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions apis/clusterresources/v1beta1/gcpvpcpeering_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ func (r *GCPVPCPeering) ValidateCreate() error {
return fmt.Errorf("peer Project ID is empty")
}

if r.Spec.DataCentreID == "" {
return fmt.Errorf("dataCentre ID is empty")
}

if r.Spec.PeerSubnets == nil {
return fmt.Errorf("peer Subnets list is empty")
}
Expand Down
6 changes: 2 additions & 4 deletions apis/clusterresources/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
)

type VPCPeeringSpec struct {
DataCentreID string `json:"cdcId,omitempty"`
PeerSubnets []string `json:"peerSubnets"`
PeerSubnets []string `json:"peerSubnets"`
}

type PeeringStatus struct {
Expand All @@ -41,8 +40,7 @@ type PatchRequest struct {
}

type FirewallRuleSpec struct {
ClusterID string `json:"clusterId,omitempty"`
Type string `json:"type"`
Type string `json:"type"`
}

type FirewallRuleStatus struct {
Expand Down
1 change: 1 addition & 0 deletions apis/clusters/v1beta1/cadence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type CadenceSpec struct {
PackagedProvisioning []*PackagedProvisioning `json:"packagedProvisioning,omitempty"`
TargetPrimaryCadence []*TargetCadence `json:"targetPrimaryCadence,omitempty"`
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
}

type AWSArchival struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type CassandraSpec struct {
Spark []*Spark `json:"spark,omitempty"`
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
UserRefs []*NamespacedName `json:"userRefs,omitempty"`
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
//+kubebuilder:validate:MaxItems:=1
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}
Expand Down Expand Up @@ -151,7 +152,6 @@ func (c *Cassandra) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.C
Finalizers: []string{models.DeletionFinalizer},
},
Spec: clusterresourcesv1beta1.ClusterBackupSpec{
ClusterID: c.Status.ID,
ClusterKind: models.CassandraClusterKind,
},
}
Expand Down
1 change: 1 addition & 0 deletions apis/clusters/v1beta1/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type KafkaSpec struct {
KarapaceSchemaRegistry []*KarapaceSchemaRegistry `json:"karapaceSchemaRegistry,omitempty"`
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
UserRefs []*NamespacedName `json:"userRefs,omitempty"`
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
Kraft []*Kraft `json:"kraft,omitempty"`
}

Expand Down
1 change: 1 addition & 0 deletions apis/clusters/v1beta1/kafkaconnect_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type KafkaConnectSpec struct {

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

// KafkaConnectStatus defines the observed state of KafkaConnect
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type OpenSearchSpec struct {
AlertingPlugin bool `json:"alertingPlugin,omitempty"`
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
UserRefs []*NamespacedName `json:"userRefs,omitempty"`
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
//+kubuilder:validation:MaxItems:=1
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}
Expand Down Expand Up @@ -551,7 +552,6 @@ func (os *OpenSearch) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1
Finalizers: []string{models.DeletionFinalizer},
},
Spec: clusterresourcesv1beta1.ClusterBackupSpec{
ClusterID: os.Status.ID,
ClusterKind: models.OsClusterKind,
},
}
Expand Down
10 changes: 0 additions & 10 deletions apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ type PgSpec struct {
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}

type ClusterResourceRefs struct {
ClusterBackups []*NamespacedName `json:"clusterBackups,omitempty"`
ClusterNetworkFirewallRules []*NamespacedName `json:"clusterNetworkFirewallRules,omitempty"`
AWSVPCPeerings []*NamespacedName `json:"awsVPCPeerings,omitempty"`
AWSSecurityGroupFirewallRules []*NamespacedName `json:"awsSecurityGroupFirewallRules,omitempty"`
ExclusionWindows []*NamespacedName `json:"exclusionWindows,omitempty"`
GCPVPCPeerings []*NamespacedName `json:"gcpVPCPeerings,omitempty"`
AzureVNetPeerings []*NamespacedName `json:"azureVNetPeerings,omitempty"`
}

// PgStatus defines the observed state of PostgreSQL
type PgStatus struct {
ClusterStatus `json:",inline"`
Expand Down
5 changes: 3 additions & 2 deletions apis/clusters/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ type RedisSpec struct {
//+kubebuilder:validation:MaxItems:=2
DataCentres []*RedisDataCentre `json:"dataCentres,omitempty"`

UserRefs []*NamespacedName `json:"userRefs,omitempty"`
UserRefs []*NamespacedName `json:"userRefs,omitempty"`
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
DataCentreNameForPeerings string `json:"dataCentreNameForPeerings,omitempty"`
//+kubebuilder:validation:MaxItems:=1
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}
Expand Down Expand Up @@ -142,7 +144,6 @@ func (r *Redis) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.Clust
Finalizers: []string{models.DeletionFinalizer},
},
Spec: clusterresourcesv1beta1.ClusterBackupSpec{
ClusterID: r.Status.ID,
ClusterKind: models.RedisClusterKind,
},
}
Expand Down
16 changes: 16 additions & 0 deletions apis/clusters/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type DataCentre struct {
}

type DataCentreStatus struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Nodes []*Node `json:"nodes,omitempty"`
Expand Down Expand Up @@ -556,6 +557,7 @@ func areClusteredMaintenanceEventStatusEqual(a, b *clusterresource.MaintenanceEv

func (cs *ClusterStatus) DCFromInstAPI(iDC models.DataCentre) *DataCentreStatus {
return &DataCentreStatus{
Name: iDC.Name,
ID: iDC.ID,
Status: iDC.Status,
Nodes: cs.NodesFromInstAPI(iDC.Nodes),
Expand Down Expand Up @@ -711,6 +713,20 @@ func (cs *ClusterStatus) PrivateLinkStatusesEqual(iStatus *ClusterStatus) bool {
return true
}

type ClusterResourceRefs struct {
ClusterBackups []*ClusterResourceRef `json:"clusterBackups,omitempty"`
ClusterNetworkFirewallRules []*ClusterResourceRef `json:"clusterNetworkFirewallRules,omitempty"`
AWSVPCPeerings []*ClusterResourceRef `json:"awsVPCPeerings,omitempty"`
AWSSecurityGroupFirewallRules []*ClusterResourceRef `json:"awsSecurityGroupFirewallRules,omitempty"`
ExclusionWindows []*ClusterResourceRef `json:"exclusionWindows,omitempty"`
GCPVPCPeerings []*ClusterResourceRef `json:"gcpVPCPeerings,omitempty"`
AzureVNetPeerings []*ClusterResourceRef `json:"azureVNetPeerings,omitempty"`
}
type ClusterResourceRef struct {
NamespacedName `json:",inline"`
DataCentreName string `json:"dataCentreName,omitempty"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Expand Down
5 changes: 3 additions & 2 deletions apis/clusters/v1beta1/zookeeper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type ZookeeperDataCentre struct {

// ZookeeperSpec defines the desired state of Zookeeper
type ZookeeperSpec struct {
Cluster `json:",inline"`
DataCentres []*ZookeeperDataCentre `json:"dataCentres"`
Cluster `json:",inline"`
DataCentres []*ZookeeperDataCentre `json:"dataCentres"`
ClusterResources ClusterResourceRefs `json:"clusterResources,omitempty"`
}

// ZookeeperStatus defines the observed state of Zookeeper
Expand Down
51 changes: 37 additions & 14 deletions apis/clusters/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ spec:
description: AWSSecurityGroupFirewallRuleSpec defines the desired state
of AWSSecurityGroupFirewallRule
properties:
clusterId:
type: string
securityGroupId:
type: string
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ spec:
spec:
description: AWSVPCPeeringSpec defines the desired state of AWSVPCPeering
properties:
cdcId:
type: string
peerAwsAccountId:
type: string
peerRegion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ spec:
spec:
description: AzureVNetPeeringSpec defines the desired state of AzureVNetPeering
properties:
cdcId:
type: string
peerAdObjectId:
type: string
peerResourceGroup:
Expand Down
Loading

0 comments on commit 181a49e

Please sign in to comment.