Skip to content

Commit 50b3366

Browse files
authored
fix: fix output error for hostname and port (#19)
1 parent 768f8ac commit 50b3366

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

examples/complete/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,13 @@ output "service_credentials_object" {
2828
value = module.icd_rabbitmq.service_credentials_object
2929
sensitive = true
3030
}
31+
32+
output "hostname" {
33+
description = "Database hostname. Only contains value when var.service_credential_names or var.users are set."
34+
value = module.icd_rabbitmq.hostname
35+
}
36+
37+
output "port" {
38+
description = "Database port. Only contains value when var.service_credential_names or var.users are set."
39+
value = module.icd_rabbitmq.port
40+
}

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ output "service_credentials_object" {
4141

4242
output "hostname" {
4343
description = "Database hostname. Only contains value when var.service_credential_names or var.users are set."
44-
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.https.hosts.0.hostname"]) : length(var.users) > 0 ? nonsensitive(flatten(data.ibm_database_connection.database_connection[0].https[0].hosts[0].hostname)) : null
44+
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.https.hosts.0.hostname"]) : length(var.users) > 0 ? data.ibm_database_connection.database_connection[0].https[0].hosts[0].hostname : null
4545
}
4646

4747
output "port" {
4848
description = "Database port. Only contains value when var.service_credential_names or var.users are set."
49-
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.https.hosts.0.port"]) : length(var.users) > 0 ? nonsensitive(flatten(data.ibm_database_connection.database_connection[0].https[0].hosts[0].port)) : null
49+
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.https.hosts.0.port"]) : length(var.users) > 0 ? data.ibm_database_connection.database_connection[0].https[0].hosts[0].port : null
5050
}

tests/pr_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"testing"
1010

11+
"github.com/gruntwork-io/terratest/modules/terraform"
1112
"github.com/stretchr/testify/assert"
1213
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
1314
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
@@ -62,10 +63,15 @@ func TestRunComplete(t *testing.T) {
6263
"admin_pass": randomPass,
6364
},
6465
})
65-
66+
options.SkipTestTearDown = true
6667
output, err := options.RunTestConsistency()
6768
assert.Nil(t, err, "This should not have errored")
6869
assert.NotNil(t, output, "Expected some output")
70+
outputs := terraform.OutputAll(options.Testing, options.TerraformOptions)
71+
expectedOutputs := []string{"port", "hostname"}
72+
_, outputErr := testhelper.ValidateTerraformOutputs(outputs, expectedOutputs...)
73+
assert.NoErrorf(t, outputErr, "Some outputs not found or nil")
74+
options.TestTearDown()
6975
}
7076

7177
func TestRunUpgradeExample(t *testing.T) {

0 commit comments

Comments
 (0)