Skip to content

Commit

Permalink
zookeeper cr codebase was refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
worryg0d authored and testisnullus committed Feb 28, 2024
1 parent b96af06 commit 285d710
Show file tree
Hide file tree
Showing 55 changed files with 544 additions and 1,472 deletions.
50 changes: 31 additions & 19 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -169,14 +165,14 @@
"filename": "apis/clusters/v1beta1/cadence_types.go",
"hashed_secret": "a242f4a16b957f7ff99eb24e189e94d270d2348b",
"is_verified": false,
"line_number": 293
"line_number": 291
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cadence_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 302
"line_number": 300
}
],
"apis/clusters/v1beta1/cassandra_types.go": [
Expand All @@ -185,21 +181,21 @@
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "331cc743251c3b9504229de4d139c539da121a33",
"is_verified": false,
"line_number": 253
"line_number": 241
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "0ad8d7005e084d4f028a4277b73c6fab24269c17",
"is_verified": false,
"line_number": 340
"line_number": 328
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "e0a46b27231f798fe22dc4d5d82b5feeb5dcf085",
"is_verified": false,
"line_number": 427
"line_number": 415
}
],
"apis/clusters/v1beta1/cassandra_webhook.go": [
Expand All @@ -208,7 +204,7 @@
"filename": "apis/clusters/v1beta1/cassandra_webhook.go",
"hashed_secret": "e0a46b27231f798fe22dc4d5d82b5feeb5dcf085",
"is_verified": false,
"line_number": 235
"line_number": 236
}
],
"apis/clusters/v1beta1/kafka_types.go": [
Expand All @@ -217,14 +213,14 @@
"filename": "apis/clusters/v1beta1/kafka_types.go",
"hashed_secret": "964c67cddfe8e6707157152dcf319126502199dc",
"is_verified": false,
"line_number": 274
"line_number": 262
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafka_types.go",
"hashed_secret": "589a0ad3cc6bc886a00c46a22e5065c48bd8e1b2",
"is_verified": false,
"line_number": 434
"line_number": 422
}
],
"apis/clusters/v1beta1/kafkaconnect_types.go": [
Expand Down Expand Up @@ -305,21 +301,21 @@
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 371
"line_number": 369
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a3d7d4a96d18c8fc5a1cf9c9c01c45b4690b4008",
"is_verified": false,
"line_number": 377
"line_number": 375
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 440
"line_number": 438
}
],
"apis/clusters/v1beta1/redis_types.go": [
Expand Down Expand Up @@ -351,7 +347,7 @@
"filename": "apis/clusters/v1beta1/redis_webhook.go",
"hashed_secret": "bc1c5ae5fd4a238d86261f422e62c489de408c22",
"is_verified": false,
"line_number": 322
"line_number": 323
}
],
"apis/clusters/v1beta1/zz_generated.deepcopy.go": [
Expand All @@ -360,7 +356,7 @@
"filename": "apis/clusters/v1beta1/zz_generated.deepcopy.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 1316
"line_number": 665
}
],
"apis/kafkamanagement/v1beta1/kafkauser_types.go": [
Expand Down Expand Up @@ -529,6 +525,22 @@
"line_number": 51
}
],
"controllers/clusters/helpers.go": [
{
"type": "Secret Keyword",
"filename": "controllers/clusters/helpers.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 119
},
{
"type": "Secret Keyword",
"filename": "controllers/clusters/helpers.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 124
}
],
"controllers/clusters/kafkaconnect_controller_test.go": [
{
"type": "Secret Keyword",
Expand Down Expand Up @@ -709,7 +721,7 @@
"filename": "pkg/instaclustr/client.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 2078
"line_number": 2084
}
],
"pkg/instaclustr/mock/client.go": [
Expand Down Expand Up @@ -1116,5 +1128,5 @@
}
]
},
"generated_at": "2024-02-28T09:07:57Z"
"generated_at": "2024-02-28T14:20:52Z"
}
14 changes: 5 additions & 9 deletions apis/clusters/v1beta1/cadence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
type CadenceDataCentre struct {
GenericDataCentreSpec `json:",inline"`

NumberOfNodes int `json:"numberOfNodes"`
NodesNumber int `json:"nodesNumber"`
NodeSize string `json:"nodeSize"`
ClientEncryption bool `json:"clientEncryption,omitempty"`

Expand Down Expand Up @@ -138,8 +138,6 @@ type CadenceStatus struct {
type CadenceDataCentreStatus struct {
GenericDataCentreStatus `json:",inline"`

NumberOfNodes int `json:"numberOfNodes,omitempty"`

Nodes []*Node `json:"nodes,omitempty"`
PrivateLink PrivateLinkStatuses `json:"privateLink,omitempty"`
}
Expand Down Expand Up @@ -322,7 +320,7 @@ func (cdc *CadenceDataCentre) ToInstAPI() *models.CadenceDataCentre {
GenericDataCentreFields: cdc.GenericDataCentreSpec.ToInstAPI(),
PrivateLink: cdc.PrivateLink.ToInstAPI(),
ClientToClusterEncryption: cdc.ClientEncryption,
NumberOfNodes: cdc.NumberOfNodes,
NumberOfNodes: cdc.NodesNumber,
NodeSize: cdc.NodeSize,
}
}
Expand Down Expand Up @@ -526,14 +524,13 @@ func (c *Cadence) GetHeadlessPorts() []k8scorev1.ServicePort {

func (cdc *CadenceDataCentreStatus) FromInstAPI(instaModel *models.CadenceDataCentre) {
cdc.GenericDataCentreStatus.FromInstAPI(&instaModel.GenericDataCentreFields)
cdc.NumberOfNodes = instaModel.NumberOfNodes
cdc.Nodes = nodesFromInstAPI(instaModel.Nodes)
cdc.PrivateLink.FromInstAPI(instaModel.PrivateLink)
}

func (cdc *CadenceDataCentre) Equals(o *CadenceDataCentre) bool {
return cdc.GenericDataCentreSpec.Equals(&o.GenericDataCentreSpec) &&
cdc.NumberOfNodes == o.NumberOfNodes &&
cdc.NodesNumber == o.NodesNumber &&
cdc.NodeSize == o.NodeSize &&
cdc.ClientEncryption == o.ClientEncryption &&
slices.EqualsPtr(cdc.PrivateLink, o.PrivateLink)
Expand All @@ -543,7 +540,7 @@ func (cdc *CadenceDataCentre) FromInstAPI(instaModel *models.CadenceDataCentre)
cdc.GenericDataCentreSpec.FromInstAPI(&instaModel.GenericDataCentreFields)
cdc.PrivateLink.FromInstAPI(instaModel.PrivateLink)

cdc.NumberOfNodes = instaModel.NumberOfNodes
cdc.NodesNumber = instaModel.NumberOfNodes
cdc.NodeSize = instaModel.NodeSize
cdc.ClientEncryption = instaModel.ClientToClusterEncryption
}
Expand Down Expand Up @@ -581,6 +578,5 @@ func (cs *CadenceStatus) DCsEqual(o []*CadenceDataCentreStatus) bool {
func (cdc *CadenceDataCentreStatus) Equals(o *CadenceDataCentreStatus) bool {
return cdc.GenericDataCentreStatus.Equals(&o.GenericDataCentreStatus) &&
cdc.PrivateLink.Equal(o.PrivateLink) &&
nodesEqual(cdc.Nodes, o.Nodes) &&
cdc.NumberOfNodes == o.NumberOfNodes
nodesEqual(cdc.Nodes, o.Nodes)
}
4 changes: 2 additions & 2 deletions apis/clusters/v1beta1/cadence_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ func (cs *CadenceSpec) validateImmutableDataCentresFieldsUpdate(oldSpec CadenceS
return fmt.Errorf("cannot update immutable data centre fields: new spec: %v: old spec: %v", newDCImmutableFields, oldDCImmutableFields)
}

if newDC.NumberOfNodes < oldDC.NumberOfNodes {
return fmt.Errorf("deleting nodes is not supported. Number of nodes must be greater than: %v", oldDC.NumberOfNodes)
if newDC.NodesNumber < oldDC.NodesNumber {
return fmt.Errorf("deleting nodes is not supported. Number of nodes must be greater than: %v", oldDC.NodesNumber)
}

err := newDC.validateImmutableCloudProviderSettingsUpdate(&oldDC.GenericDataCentreSpec)
Expand Down
14 changes: 1 addition & 13 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type CassandraRestoreFrom struct {
type CassandraSpec struct {
GenericClusterSpec `json:",inline"`

RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty"`
RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty" dcomparisonSkip:"true"`
DataCentres []*CassandraDataCentre `json:"dataCentres,omitempty"`
LuceneEnabled bool `json:"luceneEnabled,omitempty"`
PasswordAndUserAuth bool `json:"passwordAndUserAuth,omitempty"`
Expand All @@ -73,18 +73,6 @@ type CassandraStatus struct {
AvailableUsers References `json:"availableUsers,omitempty"`
}

func (s *CassandraStatus) ToOnPremises() ClusterStatus {
dc := &DataCentreStatus{
ID: s.DataCentres[0].ID,
Nodes: s.DataCentres[0].Nodes,
}

return ClusterStatus{
ID: s.ID,
DataCentres: []*DataCentreStatus{dc},
}
}

func (s *CassandraStatus) Equals(o *CassandraStatus) bool {
return s.GenericStatus.Equals(&o.GenericStatus) &&
s.DataCentresEqual(o)
Expand Down
12 changes: 0 additions & 12 deletions apis/clusters/v1beta1/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,6 @@ func (s *KafkaStatus) DCsEqual(o *KafkaStatus) bool {
return true
}

func (s *KafkaStatus) ToOnPremises() ClusterStatus {
dc := &DataCentreStatus{
ID: s.DataCentres[0].ID,
Nodes: s.DataCentres[0].Nodes,
}

return ClusterStatus{
ID: s.ID,
DataCentres: []*DataCentreStatus{dc},
}
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Expand Down
8 changes: 4 additions & 4 deletions apis/clusters/v1beta1/kafkaconnect_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type KafkaConnectDataCentre struct {
GenericDataCentreSpec `json:",inline"`

NodeSize string `json:"nodeSize"`
NumberOfNodes int `json:"numberOfNodes"`
NodesNumber int `json:"nodesNumber"`
ReplicationFactor int `json:"replicationFactor"`
}

Expand Down Expand Up @@ -239,13 +239,13 @@ func (k *KafkaConnectDataCentre) FromInstAPI(instaModel *models.KafkaConnectData
k.GenericDataCentreSpec.FromInstAPI(&instaModel.GenericDataCentreFields)

k.NodeSize = instaModel.NodeSize
k.NumberOfNodes = instaModel.NumberOfNodes
k.NodesNumber = instaModel.NumberOfNodes
k.ReplicationFactor = instaModel.ReplicationFactor
}

func (k *KafkaConnectDataCentre) Equals(o *KafkaConnectDataCentre) bool {
return k.GenericDataCentreSpec.Equals(&o.GenericDataCentreSpec) &&
k.NumberOfNodes == o.NumberOfNodes &&
k.NodesNumber == o.NodesNumber &&
k.ReplicationFactor == o.ReplicationFactor &&
k.NodeSize == o.NodeSize
}
Expand Down Expand Up @@ -461,7 +461,7 @@ func (kdc *KafkaConnectDataCentre) ToInstAPI() *models.KafkaConnectDataCentre {
return &models.KafkaConnectDataCentre{
GenericDataCentreFields: kdc.GenericDataCentreSpec.ToInstAPI(),
NodeSize: kdc.NodeSize,
NumberOfNodes: kdc.NumberOfNodes,
NumberOfNodes: kdc.NodesNumber,
ReplicationFactor: kdc.ReplicationFactor,
}
}
Expand Down
8 changes: 4 additions & 4 deletions apis/clusters/v1beta1/kafkaconnect_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (kcv *kafkaConnectValidator) ValidateCreate(ctx context.Context, obj runtim
return err
}

if ((dc.NumberOfNodes*dc.ReplicationFactor)/dc.ReplicationFactor)%dc.ReplicationFactor != 0 {
if ((dc.NodesNumber*dc.ReplicationFactor)/dc.ReplicationFactor)%dc.ReplicationFactor != 0 {
return fmt.Errorf("number of nodes must be a multiple of replication factor: %v", dc.ReplicationFactor)
}
}
Expand Down Expand Up @@ -284,11 +284,11 @@ func (kc *KafkaConnectSpec) validateImmutableDataCentresFieldsUpdate(oldSpec Kaf
return err
}

if newDC.NumberOfNodes < oldDC.NumberOfNodes {
return fmt.Errorf("deleting nodes is not supported. Number of nodes must be greater than: %v", oldDC.NumberOfNodes)
if newDC.NodesNumber < oldDC.NodesNumber {
return fmt.Errorf("deleting nodes is not supported. Number of nodes must be greater than: %v", oldDC.NodesNumber)
}

if ((newDC.NumberOfNodes*newDC.ReplicationFactor)/newDC.ReplicationFactor)%newDC.ReplicationFactor != 0 {
if ((newDC.NodesNumber*newDC.ReplicationFactor)/newDC.ReplicationFactor)%newDC.ReplicationFactor != 0 {
return fmt.Errorf("number of nodes must be a multiple of replication factor: %v", newDC.ReplicationFactor)
}
}
Expand Down
14 changes: 5 additions & 9 deletions apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type PgDataCentre struct {
// PostgreSQL options
ClientEncryption bool `json:"clientEncryption"`
NodeSize string `json:"nodeSize"`
NumberOfNodes int `json:"numberOfNodes"`
NodesNumber int `json:"nodesNumber"`

//+kubebuilder:Validation:MaxItems:=1
InterDataCentreReplication []*InterDataCentreReplication `json:"interDataCentreReplication,omitempty"`
Expand Down Expand Up @@ -102,9 +102,7 @@ type PgStatus struct {

type PgDataCentreStatus struct {
GenericDataCentreStatus `json:",inline"`

NumberOfNodes int `json:"numberOfNodes"`
Nodes []*Node `json:"nodes"`
Nodes []*Node `json:"nodes"`
}

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -244,7 +242,7 @@ func (pdc *PgDataCentre) ToInstAPI() *models.PGDataCentre {
InterDataCentreReplication: pdc.InterDCReplicationToInstAPI(),
IntraDataCentreReplication: pdc.IntraDCReplicationToInstAPI(),
NodeSize: pdc.NodeSize,
NumberOfNodes: pdc.NumberOfNodes,
NumberOfNodes: pdc.NodesNumber,
}
}

Expand Down Expand Up @@ -505,7 +503,7 @@ func (p PgExtensions) ToInstAPI() []*models.PGExtension {
func (pdc *PgDataCentre) Equals(o *PgDataCentre) bool {
return pdc.GenericDataCentreSpec.Equals(&o.GenericDataCentreSpec) &&
pdc.ClientEncryption == o.ClientEncryption &&
pdc.NumberOfNodes == o.NumberOfNodes &&
pdc.NodesNumber == o.NodesNumber &&
pdc.NodeSize == o.NodeSize &&
slices.EqualsPtr(pdc.InterDataCentreReplication, o.InterDataCentreReplication) &&
slices.EqualsPtr(pdc.IntraDataCentreReplication, o.IntraDataCentreReplication) &&
Expand All @@ -517,7 +515,7 @@ func (pdc *PgDataCentre) FromInstAPI(instaModel *models.PGDataCentre) {

pdc.ClientEncryption = instaModel.ClientToClusterEncryption
pdc.NodeSize = instaModel.NodeSize
pdc.NumberOfNodes = instaModel.NumberOfNodes
pdc.NodesNumber = instaModel.NumberOfNodes

pdc.InterReplicationsFromInstAPI(instaModel.InterDataCentreReplication)
pdc.IntraReplicationsFromInstAPI(instaModel.IntraDataCentreReplication)
Expand Down Expand Up @@ -562,12 +560,10 @@ func (pgs *PgSpec) ClusterConfigurationsFromInstAPI(instaModels []*models.Cluste
func (s *PgDataCentreStatus) FromInstAPI(instaModel *models.PGDataCentre) {
s.GenericDataCentreStatus.FromInstAPI(&instaModel.GenericDataCentreFields)
s.Nodes = nodesFromInstAPI(instaModel.Nodes)
s.NumberOfNodes = instaModel.NumberOfNodes
}

func (s *PgDataCentreStatus) Equals(o *PgDataCentreStatus) bool {
return s.GenericDataCentreStatus.Equals(&o.GenericDataCentreStatus) &&
s.NumberOfNodes == o.NumberOfNodes &&
nodesEqual(s.Nodes, o.Nodes)
}

Expand Down
Loading

0 comments on commit 285d710

Please sign in to comment.