Skip to content

Commit

Permalink
kafka code base refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
worryg0d committed Feb 14, 2024
1 parent 10a2b46 commit db62598
Show file tree
Hide file tree
Showing 36 changed files with 546 additions and 542 deletions.
62 changes: 29 additions & 33 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 @@ -185,21 +181,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": 390
}
],
"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": 229
"line_number": 230
}
],
"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": 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 +229,84 @@
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "46fe9b29395041087f91b33bd8c5c6177cd42fd1",
"is_verified": false,
"line_number": 246
"line_number": 245
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "4b3af1508421e2fa591c5b260c36dd06fdd872a5",
"is_verified": false,
"line_number": 284
"line_number": 283
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "cf45830dd81b7e1a8b5ffbc2d95b112771524117",
"is_verified": false,
"line_number": 294
"line_number": 293
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "138905ac46675150bf790088ec56b2efc6a64697",
"is_verified": false,
"line_number": 305
"line_number": 304
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "3948059919ffeee8ecc42149cb386f43d2f06f74",
"is_verified": false,
"line_number": 310
"line_number": 309
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "87f1180476a944c4162d1af55efedc8f3e3b609c",
"is_verified": false,
"line_number": 519
"line_number": 444
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "f0f06c9167ce61a586749bb183ac6a3756dd6010",
"is_verified": false,
"line_number": 529
"line_number": 454
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "2042128e13ef5ede4af44271160c72f64564c632",
"is_verified": false,
"line_number": 540
"line_number": 465
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "82dc9ca8ba09262ce948227aeb5d9db8084eeb5d",
"is_verified": false,
"line_number": 545
"line_number": 470
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5f915325aef923cdc945f639f14c2f854b4214d6",
"is_verified": false,
"line_number": 569
"line_number": 494
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 602
"line_number": 527
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 607
"line_number": 532
}
],
"apis/clusters/v1beta1/postgresql_types.go": [
Expand All @@ -319,21 +315,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 +338,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 +361,7 @@
"filename": "apis/clusters/v1beta1/redis_webhook.go",
"hashed_secret": "bc1c5ae5fd4a238d86261f422e62c489de408c22",
"is_verified": false,
"line_number": 316
"line_number": 317
}
],
"apis/clusters/v1beta1/zookeeper_types.go": [
Expand All @@ -390,7 +386,7 @@
"filename": "apis/clusters/v1beta1/zz_generated.deepcopy.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 2290
"line_number": 2303
}
],
"apis/kafkamanagement/v1beta1/kafkauser_types.go": [
Expand Down Expand Up @@ -531,7 +527,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 +735,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 @@ -1130,5 +1126,5 @@
}
]
},
"generated_at": "2024-02-12T11:41:39Z"
"generated_at": "2024-02-14T12:37:19Z"
}
29 changes: 4 additions & 25 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,6 +324,7 @@ 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)
Expand Down Expand Up @@ -411,6 +389,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 @@ -207,6 +207,7 @@ type immutableCassandraFields struct {
type specificCassandra struct {
LuceneEnabled bool
PasswordAndUserAuth bool
PCICompliance bool
}

type immutableCassandraDCFields struct {
Expand All @@ -227,6 +228,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 db62598

Please sign in to comment.