Skip to content

Commit ccc4746

Browse files
fix: fixed bug that can produce the error Invalid value for "value" parameter: the given value is not sensitive, so this call is redundant if not passing any values for the users and service_credential_names variables (#204)
1 parent 56ed5f5 commit ccc4746

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

main.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,3 @@ data "ibm_database_connection" "database_connection" {
214214
user_id = var.users[0].name
215215
user_type = var.users[0].type
216216
}
217-
218-
locals {
219-
# Used for output only
220-
hostname = length(var.service_credential_names) > 0 ? ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.postgres.hosts.0.hostname"] : length(var.users) > 0 ? flatten(data.ibm_database_connection.database_connection[0].postgres[0].hosts[0].hostname) : null
221-
port = length(var.service_credential_names) > 0 ? ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.postgres.hosts.0.port"] : length(var.users) > 0 ? flatten(data.ibm_database_connection.database_connection[0].postgres[0].hosts[0].port) : null
222-
}

outputs.tf

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

4242
output "hostname" {
4343
description = "Database hostname. Only contains value when var.service_credential_names or var.users are set."
44-
value = nonsensitive(local.hostname)
44+
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.postgres.hosts.0.hostname"]) : length(var.users) > 0 ? nonsensitive(flatten(data.ibm_database_connection.database_connection[0].postgres[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 = nonsensitive(local.port)
49+
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.postgres.hosts.0.port"]) : length(var.users) > 0 ? nonsensitive(flatten(data.ibm_database_connection.database_connection[0].postgres[0].hosts[0].port)) : null
5050
}

tests/pr_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ func TestRunUpgradeCompleteExample(t *testing.T) {
7171
_, err := rand.Read(randomBytes)
7272
randomPass := base64.URLEncoding.EncodeToString(randomBytes)[:10]
7373

74-
// User Object
75-
type User struct {
76-
Name string
77-
Password string
78-
Type string
79-
}
80-
81-
users := []User{
82-
{Name: "testuser", Password: randomPass, Type: "database"}, // pragma: allowlist secret
83-
}
84-
8574
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
8675
Testing: t,
8776
TerraformDir: "examples/complete",
@@ -90,7 +79,13 @@ func TestRunUpgradeCompleteExample(t *testing.T) {
9079
ResourceGroup: resourceGroup,
9180
TerraformVars: map[string]interface{}{
9281
"pg_version": "11", // Always lock to the lowest supported Postgres version
93-
"users": users,
82+
"users": []map[string]interface{}{
83+
{
84+
"name": "testuser",
85+
"password": randomPass, // pragma: allowlist secret
86+
"type": "database",
87+
},
88+
},
9489
"admin_pass": randomPass,
9590
},
9691
})

0 commit comments

Comments
 (0)