Skip to content

Commit

Permalink
KafkaConnect code base refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
worryg0d committed Feb 19, 2024
1 parent f8be757 commit e0df0d7
Show file tree
Hide file tree
Showing 38 changed files with 603 additions and 596 deletions.
58 changes: 29 additions & 29 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,21 @@
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "331cc743251c3b9504229de4d139c539da121a33",
"is_verified": false,
"line_number": 261
"line_number": 238
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "0ad8d7005e084d4f028a4277b73c6fab24269c17",
"is_verified": false,
"line_number": 347
"line_number": 324
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "e0a46b27231f798fe22dc4d5d82b5feeb5dcf085",
"is_verified": false,
"line_number": 412
"line_number": 402
}
],
"apis/clusters/v1beta1/cassandra_webhook.go": [
Expand All @@ -208,7 +208,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 +217,14 @@
"filename": "apis/clusters/v1beta1/kafka_types.go",
"hashed_secret": "964c67cddfe8e6707157152dcf319126502199dc",
"is_verified": false,
"line_number": 293
"line_number": 271
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafka_types.go",
"hashed_secret": "589a0ad3cc6bc886a00c46a22e5065c48bd8e1b2",
"is_verified": false,
"line_number": 439
"line_number": 418
}
],
"apis/clusters/v1beta1/kafkaconnect_types.go": [
Expand All @@ -233,84 +233,84 @@
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "46fe9b29395041087f91b33bd8c5c6177cd42fd1",
"is_verified": false,
"line_number": 247
"line_number": 251
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "4b3af1508421e2fa591c5b260c36dd06fdd872a5",
"is_verified": false,
"line_number": 285
"line_number": 295
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "cf45830dd81b7e1a8b5ffbc2d95b112771524117",
"is_verified": false,
"line_number": 295
"line_number": 305
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "138905ac46675150bf790088ec56b2efc6a64697",
"is_verified": false,
"line_number": 306
"line_number": 316
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "3948059919ffeee8ecc42149cb386f43d2f06f74",
"is_verified": false,
"line_number": 311
"line_number": 321
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "87f1180476a944c4162d1af55efedc8f3e3b609c",
"is_verified": false,
"line_number": 520
"line_number": 456
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "f0f06c9167ce61a586749bb183ac6a3756dd6010",
"is_verified": false,
"line_number": 530
"line_number": 466
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "2042128e13ef5ede4af44271160c72f64564c632",
"is_verified": false,
"line_number": 541
"line_number": 477
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "82dc9ca8ba09262ce948227aeb5d9db8084eeb5d",
"is_verified": false,
"line_number": 546
"line_number": 482
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5f915325aef923cdc945f639f14c2f854b4214d6",
"is_verified": false,
"line_number": 570
"line_number": 506
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 603
"line_number": 539
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 608
"line_number": 544
}
],
"apis/clusters/v1beta1/postgresql_types.go": [
Expand All @@ -319,21 +319,21 @@
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 355
"line_number": 354
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a3d7d4a96d18c8fc5a1cf9c9c01c45b4690b4008",
"is_verified": false,
"line_number": 361
"line_number": 360
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 481
"line_number": 480
}
],
"apis/clusters/v1beta1/redis_types.go": [
Expand All @@ -342,21 +342,21 @@
"filename": "apis/clusters/v1beta1/redis_types.go",
"hashed_secret": "bc1c5ae5fd4a238d86261f422e62c489de408c22",
"is_verified": false,
"line_number": 168
"line_number": 169
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/redis_types.go",
"hashed_secret": "d62d56668a8c859e768e8250ed2fb690d03cead3",
"is_verified": false,
"line_number": 223
"line_number": 225
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/redis_types.go",
"hashed_secret": "d0e8e6fc5dce4d2b452e344ae41900b566ac01d1",
"is_verified": false,
"line_number": 268
"line_number": 270
}
],
"apis/clusters/v1beta1/redis_webhook.go": [
Expand All @@ -365,7 +365,7 @@
"filename": "apis/clusters/v1beta1/redis_webhook.go",
"hashed_secret": "bc1c5ae5fd4a238d86261f422e62c489de408c22",
"is_verified": false,
"line_number": 322
"line_number": 323
}
],
"apis/clusters/v1beta1/zookeeper_types.go": [
Expand All @@ -390,7 +390,7 @@
"filename": "apis/clusters/v1beta1/zz_generated.deepcopy.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 1322
"line_number": 1252
}
],
"apis/kafkamanagement/v1beta1/kafkauser_types.go": [
Expand Down Expand Up @@ -531,7 +531,7 @@
"filename": "controllers/clusters/cadence_controller.go",
"hashed_secret": "bcf196cdeea4d7ed8b04dcbbd40111eb5e9abeac",
"is_verified": false,
"line_number": 660
"line_number": 661
},
{
"type": "Secret Keyword",
Expand Down Expand Up @@ -739,7 +739,7 @@
"filename": "pkg/instaclustr/client.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 2060
"line_number": 2066
}
],
"pkg/instaclustr/mock/client.go": [
Expand Down Expand Up @@ -1146,5 +1146,5 @@
}
]
},
"generated_at": "2024-02-16T12:41:16Z"
"generated_at": "2024-02-19T08:52:45Z"
}
49 changes: 20 additions & 29 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type CassandraSpec struct {
LuceneEnabled bool `json:"luceneEnabled,omitempty"`
PasswordAndUserAuth bool `json:"passwordAndUserAuth,omitempty"`
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
PCICompliance bool `json:"pciCompliance,omitempty"`
UserRefs References `json:"userRefs,omitempty"`
ResizeSettings GenericResizeSettings `json:"resizeSettings,omitempty"`
}
Expand Down Expand Up @@ -147,31 +148,7 @@ type CassandraDataCentreStatus struct {

func (s *CassandraDataCentreStatus) Equals(o *CassandraDataCentreStatus) bool {
return s.GenericDataCentreStatus.Equals(&o.GenericDataCentreStatus) &&
s.nodesEqual(o.Nodes)
}

func (s *CassandraDataCentreStatus) nodesEqual(nodes []*Node) bool {
if len(s.Nodes) != len(nodes) {
return false
}

sNodes := map[string]*Node{}
for _, node := range s.Nodes {
sNodes[node.ID] = node
}

for _, node := range nodes {
sNode, ok := sNodes[node.ID]
if !ok {
return false
}

if !sNode.Equals(node) {
return false
}
}

return true
nodesEqual(s.Nodes, o.Nodes)
}

func (s *CassandraDataCentreStatus) FromInstAPI(instModel *models.CassandraDataCentre) {
Expand Down Expand Up @@ -347,18 +324,26 @@ func (cs *CassandraSpec) FromInstAPI(instModel *models.CassandraCluster) {
cs.PasswordAndUserAuth = instModel.PasswordAndUserAuth
cs.BundledUseOnly = instModel.BundledUseOnly
cs.Version = instModel.CassandraVersion
cs.PCICompliance = instModel.PCIComplianceMode
cs.ResizeSettings.FromInstAPI(instModel.ResizeSettings)

cs.dcsFromInstAPI(instModel.DataCentres)
}

func (cs *CassandraSpec) dcsFromInstAPI(instModels []*models.CassandraDataCentre) {
cs.DataCentres = make([]*CassandraDataCentre, len(instModels))
dcs := make([]*CassandraDataCentre, len(instModels))
for i, instModel := range instModels {
dc := &CassandraDataCentre{}

if len(cs.DataCentres) > 0 {
dc.Debezium = cs.DataCentres[i].Debezium
}

dc.FromInstAPI(instModel)
cs.DataCentres[i] = dc
dcs[i] = dc
}

cs.DataCentres = dcs
}

func (d *CassandraDataCentre) FromInstAPI(instModel *models.CassandraDataCentre) {
Expand All @@ -377,15 +362,20 @@ func (d *CassandraDataCentre) FromInstAPI(instModel *models.CassandraDataCentre)
}

func (cs *CassandraDataCentre) debeziumFromInstAPI(instModels []*models.Debezium) {
cs.Debezium = make([]*DebeziumCassandraSpec, len(instModels))
debezium := make([]*DebeziumCassandraSpec, len(instModels))
for i, instModel := range instModels {
cs.Debezium[i] = &DebeziumCassandraSpec{
debezium[i] = &DebeziumCassandraSpec{
KafkaVPCType: instModel.KafkaVPCType,
KafkaTopicPrefix: instModel.KafkaTopicPrefix,
KafkaDataCentreID: instModel.KafkaDataCentreID,
Version: instModel.Version,
}

if len(cs.Debezium) > 0 {
debezium[i].ClusterRef = cs.Debezium[i].ClusterRef
}
}
cs.Debezium = debezium
}

func (cs *CassandraDataCentre) shotoverProxyFromInstAPI(instModels []*models.ShotoverProxy) {
Expand All @@ -411,6 +401,7 @@ func (cs *CassandraSpec) ToInstAPI() *models.CassandraCluster {
LuceneEnabled: cs.LuceneEnabled,
PasswordAndUserAuth: cs.PasswordAndUserAuth,
BundledUseOnly: cs.BundledUseOnly,
PCIComplianceMode: cs.PCICompliance,
DataCentres: cs.DCsToInstAPI(),
ResizeSettings: cs.ResizeSettings.ToInstAPI(),
}
Expand Down
2 changes: 2 additions & 0 deletions apis/clusters/v1beta1/cassandra_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ type immutableCassandraFields struct {
type specificCassandra struct {
LuceneEnabled bool
PasswordAndUserAuth bool
PCICompliance bool
}

type immutableCassandraDCFields struct {
Expand All @@ -233,6 +234,7 @@ func (cs *CassandraSpec) newImmutableFields() *immutableCassandraFields {
specificCassandra: specificCassandra{
LuceneEnabled: cs.LuceneEnabled,
PasswordAndUserAuth: cs.PasswordAndUserAuth,
PCICompliance: cs.PCICompliance,
},
immutableCluster: cs.GenericClusterSpec.immutableFields(),
}
Expand Down
7 changes: 0 additions & 7 deletions apis/clusters/v1beta1/generic_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ type GenericClusterSpec struct {

Version string `json:"version,omitempty"`

// The PCI compliance standards relate to the security of user data and transactional information.
// Can only be applied clusters provisioned on AWS_VPC, running Cassandra, Kafka, Elasticsearch and Redis.
PCICompliance bool `json:"pciCompliance,omitempty"`

PrivateNetwork bool `json:"privateNetwork,omitempty"`

// Non-production clusters may receive lower priority support and reduced SLAs.
Expand All @@ -30,7 +26,6 @@ type GenericClusterSpec struct {
func (s *GenericClusterSpec) Equals(o *GenericClusterSpec) bool {
return s.Name == o.Name &&
s.Version == o.Version &&
s.PCICompliance == o.PCICompliance &&
s.PrivateNetwork == o.PrivateNetwork &&
s.SLATier == o.SLATier &&
s.Description == o.Description &&
Expand All @@ -39,7 +34,6 @@ func (s *GenericClusterSpec) Equals(o *GenericClusterSpec) bool {

func (s *GenericClusterSpec) FromInstAPI(model *models.GenericClusterFields) {
s.Name = model.Name
s.PCICompliance = model.PCIComplianceMode
s.PrivateNetwork = model.PrivateNetworkCluster
s.SLATier = model.SLATier
s.Description = model.Description
Expand All @@ -60,7 +54,6 @@ func (s *GenericClusterSpec) ToInstAPI() models.GenericClusterFields {
return models.GenericClusterFields{
Name: s.Name,
Description: s.Description,
PCIComplianceMode: s.PCICompliance,
PrivateNetworkCluster: s.PrivateNetwork,
SLATier: s.SLATier,
TwoFactorDelete: s.TwoFactorDeleteToInstAPI(),
Expand Down
Loading

0 comments on commit e0df0d7

Please sign in to comment.