Skip to content

Commit

Permalink
equality fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ribaraka committed Sep 13, 2023
1 parent 8a6906b commit c38c460
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 8 deletions.
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/cadence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ func (cs *CadenceSpec) AreDCsEqual(dcs []*CadenceDataCentre) bool {

for i, iDC := range dcs {
dataCentre := cs.DataCentres[i]

if iDC.Name != dataCentre.Name {
continue
}

if !dataCentre.IsEqual(iDC.DataCentre) ||
iDC.ClientEncryption != dataCentre.ClientEncryption ||
!arePrivateLinksEqual(dataCentre.PrivateLink, iDC.PrivateLink) {
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ func (cs *CassandraSpec) AreDCsEqual(dcs []*CassandraDataCentre) bool {

for i, iDC := range dcs {
dataCentre := cs.DataCentres[i]

if iDC.Name != dataCentre.Name {
continue
}

if !dataCentre.IsEqual(iDC.DataCentre) ||
iDC.ClientToClusterEncryption != dataCentre.ClientToClusterEncryption ||
iDC.PrivateIPBroadcastForDiscovery != dataCentre.PrivateIPBroadcastForDiscovery ||
Expand Down
4 changes: 4 additions & 0 deletions apis/clusters/v1beta1/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ func (rs *KafkaSpec) areDCsEqual(b []*KafkaDataCentre) bool {
}

for i := range b {
if a[i].Name != b[i].Name {
continue
}

if !a[i].DataCentre.IsEqual(b[i].DataCentre) ||
!isKafkaAddonsEqual[PrivateLink](a[i].PrivateLink, b[i].PrivateLink) {
return false
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/kafkaconnect_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ func (ks *KafkaConnectSpec) AreDataCentresEqual(dcs []*KafkaConnectDataCentre) b

for i, iDC := range dcs {
dataCentre := ks.DataCentres[i]

if iDC.Name != dataCentre.Name {
continue
}

if !dataCentre.IsEqual(iDC.DataCentre) ||
iDC.ReplicationFactor != dataCentre.ReplicationFactor {
return false
Expand Down
7 changes: 5 additions & 2 deletions apis/clusters/v1beta1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,11 @@ func (oss *OpenSearchSpec) areDCsEqual(b []*OpenSearchDataCentre) bool {
}

for i := range b {
if a[i].Name != b[i].Name &&
a[i].Region != b[i].Region &&
if a[i].Name != b[i].Name {
continue
}

if a[i].Region != b[i].Region &&
a[i].CloudProvider != b[i].CloudProvider &&
a[i].ProviderAccountName != b[i].ProviderAccountName &&
areCloudProviderSettingsEqual(a[i].CloudProviderSettings, b[i].CloudProviderSettings) &&
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ func (pgs *PgSpec) AreDCsEqual(iDCs []*PgDataCentre) bool {

for i, iDC := range iDCs {
dc := pgs.DataCentres[i]

if iDC.Name != dc.Name {
continue
}

if !dc.IsEqual(iDC.DataCentre) ||
dc.ClientEncryption != iDC.ClientEncryption ||
!dc.AreInterDCReplicationsEqual(iDC.InterDataCentreReplication) ||
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ func (rs *RedisSpec) AreDCsEqual(iDCs []*RedisDataCentre) bool {

for i, iDC := range iDCs {
dataCentre := rs.DataCentres[i]

if iDC.Name != dataCentre.Name {
continue
}

if !dataCentre.IsEqual(iDC.DataCentre) ||
iDC.MasterNodes != dataCentre.MasterNodes {
return false
Expand Down
3 changes: 1 addition & 2 deletions apis/clusters/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ func (dc *DataCentre) TagsToInstAPI() (tags []*models.Tag) {
}

func (dc *DataCentre) IsEqual(iDC DataCentre) bool {
return iDC.Name == dc.Name &&
iDC.Region == dc.Region &&
return iDC.Region == dc.Region &&
iDC.CloudProvider == dc.CloudProvider &&
iDC.ProviderAccountName == dc.ProviderAccountName &&
dc.AreCloudProviderSettingsEqual(iDC.CloudProviderSettings) &&
Expand Down
4 changes: 4 additions & 0 deletions apis/clusters/v1beta1/zookeeper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func (rs *ZookeeperSpec) areDCsEqual(b []*ZookeeperDataCentre) bool {
}

for i := range b {
if a[i].Name != b[i].Name {
continue
}

if !a[i].DataCentre.IsEqual(b[i].DataCentre) ||
a[i].ClientToServerEncryption != b[i].ClientToServerEncryption {
return false
Expand Down
14 changes: 10 additions & 4 deletions controllers/clusters/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ func areDataCentresEqual(a, b []*v1beta1.DataCentreStatus) bool {
}

for i := range a {
if a[i].ID != b[i].ID ||
a[i].Status != b[i].Status ||
if a[i].ID != b[i].ID {
continue
}

if a[i].Status != b[i].Status ||
a[i].NodeNumber != b[i].NodeNumber ||
a[i].EncryptionKeyID != b[i].EncryptionKeyID {
return false
Expand All @@ -115,8 +118,11 @@ func isDataCentreNodesEqual(a, b []*v1beta1.Node) bool {
}

for i := range a {
if a[i].ID != b[i].ID ||
a[i].Size != b[i].Size ||
if a[i].ID != b[i].ID {
continue
}

if a[i].Size != b[i].Size ||
a[i].PublicAddress != b[i].PublicAddress ||
a[i].PrivateAddress != b[i].PrivateAddress ||
a[i].Status != b[i].Status ||
Expand Down

0 comments on commit c38c460

Please sign in to comment.