Skip to content

Commit

Permalink
Fix cassandra_url handling to be http / https depending on SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Feb 23, 2024
1 parent 018e846 commit 2d6579e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/medusa/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func CreateMedusaIni(kc *k8ss.K8ssandraCluster, dcConfig *cassandra.DatacenterCo
level = DEBUG
[kubernetes]
cassandra_url = http://127.0.0.1:8080/api/v0/ops/node/snapshots
use_mgmt_api = 1
enabled = 1`

Expand All @@ -141,9 +140,13 @@ func CreateMedusaIni(kc *k8ss.K8ssandraCluster, dcConfig *cassandra.DatacenterCo
// Create Kubernetes config here and append it
if dcConfig.ManagementApiAuth != nil && dcConfig.ManagementApiAuth.Manual != nil {
medusaConfiig += `
cassandra_url = https://127.0.0.1:8080/api/v0/ops/node/snapshots
ca_cert = /etc/encryption/mgmt/ca.crt
tls_cert = /etc/encryption/mgmt/tls.crt
tls_key = /etc/encryption/mgmt/tls.key`
} else {
medusaConfiig += `
cassandra_url = http://127.0.0.1:8080/api/v0/ops/node/snapshots`
}

return medusaConfiig
Expand Down
3 changes: 3 additions & 0 deletions pkg/medusa/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func testMedusaIniNoPrefix(t *testing.T) {
assert.Contains(t, medusaIni, "port = 9001")
assert.Contains(t, medusaIni, "secure = False")
assert.Contains(t, medusaIni, "backup_grace_period_in_days = 7")
assert.Contains(t, medusaIni, "cassandra_url = http://127.0.0.1:8080/api/v0/ops/node/snapshots")
}

func testMedusaIniSecured(t *testing.T) {
Expand Down Expand Up @@ -234,6 +235,7 @@ func testMedusaIniSecured(t *testing.T) {
assert.Contains(medusaIni, "ca_cert = /etc/encryption/mgmt/ca.crt")
assert.Contains(medusaIni, "tls_cert = /etc/encryption/mgmt/tls.crt")
assert.Contains(medusaIni, "tls_key = /etc/encryption/mgmt/tls.key")
assert.Contains(medusaIni, "cassandra_url = https://127.0.0.1:8080/api/v0/ops/node/snapshots")
}

func testMedusaIniSecuredDcLevelSetting(t *testing.T) {
Expand Down Expand Up @@ -296,6 +298,7 @@ func testMedusaIniSecuredDcLevelSetting(t *testing.T) {
assert.Contains(medusaIni, "ca_cert = /etc/encryption/mgmt/ca.crt")
assert.Contains(medusaIni, "tls_cert = /etc/encryption/mgmt/tls.crt")
assert.Contains(medusaIni, "tls_key = /etc/encryption/mgmt/tls.key")
assert.Contains(medusaIni, "cassandra_url = https://127.0.0.1:8080/api/v0/ops/node/snapshots")
}

func testMedusaIniUnsecured(t *testing.T) {
Expand Down

0 comments on commit 2d6579e

Please sign in to comment.