Skip to content

Commit a201610

Browse files
authored
fix: DA updates:<br>- existing_user_name input has been removed<br>- user_email output has been removed<br>- fix added for incorrect validation logic (#62)
1 parent 8c273b1 commit a201610

File tree

5 files changed

+55
-48
lines changed

5 files changed

+55
-48
lines changed

ibm_catalog.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@
120120
{
121121
"key": "user_name"
122122
},
123-
{
124-
"key": "existing_user_name"
125-
},
126123
{
127124
"key": "user_email"
128125
},

solutions/standard/main.tf

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ locals {
1616
create_queue_manager = var.existing_queue_manager_name == null ? true : false
1717

1818
# Application
19-
create_application = var.existing_application_name == null ? true : false
19+
create_application = var.application_name == null ? false : true
20+
lookup_application = var.existing_application_name == null ? false : true
2021

2122
# User
22-
create_user = var.existing_user_name == null ? true : false
23+
create_user = var.user_name == null ? false : true
2324

2425
# Certificate, only supports looking up the existing default certificate
2526
create_certificate = false
@@ -94,15 +95,10 @@ module "experimental_connection" {
9495
href = local.queue_manager_href
9596
}
9697

97-
9898
########################################################################################################################
9999
# MQ queue configuraton
100100
########################################################################################################################
101101

102-
# Need to pass the user (local.user_name) and the application api key (module.experimental_api_key.api_key)
103-
# Need to pass the queue manager administrator href (local.queue_manager_administrator_api_endpoint_url)
104-
105-
106102
########################################################################################################################
107103
# MQ application
108104
########################################################################################################################
@@ -115,14 +111,15 @@ module "application" {
115111
}
116112

117113
data "ibm_mqcloud_application" "application" {
118-
count = local.create_application ? 0 : 1
114+
count = local.lookup_application ? 1 : 0
119115
name = var.existing_application_name
120116
service_instance_guid = local.mq_deployment_guid
121117
}
122118

123119
locals {
124-
application_create_api_key_uri = local.create_application ? module.application[0].create_api_key_uri : data.ibm_mqcloud_application.application[0].applications[0].create_api_key_uri
125-
application_href = local.create_application ? module.application[0].href : data.ibm_mqcloud_application.application[0].applications[0].href
120+
application_create_api_key_uri = local.create_application ? module.application[0].create_api_key_uri : local.lookup_application ? data.ibm_mqcloud_application.application[0].applications[0].create_api_key_uri : null
121+
application_href = local.create_application ? module.application[0].href : local.lookup_application ? data.ibm_mqcloud_application.application[0].applications[0].href : null
122+
application_id = local.create_application ? module.application[0].id : local.lookup_application ? data.ibm_mqcloud_application.application[0].applications[0].id : null
126123
}
127124

128125
########################################################################################################################
@@ -137,11 +134,6 @@ module "user" {
137134
service_instance_crn = local.mq_deployment_crn
138135
}
139136

140-
# For a new user, add them and use; for an existing user just use supplied name
141-
locals {
142-
user = local.create_user ? var.user_email : var.existing_user_name
143-
}
144-
145137
########################################################################################################################
146138
# MQ CA certificate
147139
########################################################################################################################

solutions/standard/outputs.tf

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ output "connection_app_type" {
140140

141141
output "application_id" {
142142
description = "The unique identifier of the mqcloud_application."
143-
value = local.create_application ? module.application[0].id : data.ibm_mqcloud_application.application[0].applications[0].id
143+
value = local.application_id
144144
}
145145

146146
output "application_create_api_key_uri" {
@@ -167,15 +167,6 @@ output "truststore_root_certificate" {
167167
sensitive = true
168168
}
169169

170-
########################################################################################################################
171-
# User
172-
########################################################################################################################
173-
174-
output "user_email" {
175-
description = "name"
176-
value = local.user
177-
}
178-
179170
########################################################################################################################
180171
# Secrets
181172
########################################################################################################################

solutions/standard/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ variable "user_name" {
120120
default = null
121121
}
122122

123-
variable "existing_user_name" {
124-
type = string
125-
description = "The name of an existing user."
126-
default = null
127-
}
128-
129123
variable "user_email" {
130124
type = string
131125
description = "The email address to given to the new user."

tests/pr_test.go

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func setupOptions(t *testing.T, prefix string, dir string) *testhelper.TestOptio
4848
}
4949

5050
func TestRunAdvancedExample(t *testing.T) {
51-
t.Parallel()
51+
// t.Parallel()
5252

5353
options := setupOptions(t, "mqoc", advancedExampleDir)
5454

@@ -58,26 +58,29 @@ func TestRunAdvancedExample(t *testing.T) {
5858
}
5959

6060
func TestRunUpgradeExample(t *testing.T) {
61-
t.Parallel()
61+
// t.Parallel()
6262

6363
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
6464
Testing: t,
6565
TerraformDir: standardSolutionTerraformDir,
6666
Prefix: "mq",
6767
Region: "us-east",
68-
TerraformVars: map[string]interface{}{
69-
"existing_mq_capacity_crn": permanentResources["mq_capacity_crn"],
70-
"deployment_name": "da-upg-instance",
71-
"queue_manager_name": "da_upg",
72-
"queue_manager_display_name": "da-upg-display",
73-
"queue_manager_size": "xsmall",
74-
"resource_group_name": "mq",
75-
"application_name": "app",
76-
"user_email": "mq-user@exmaple.com",
77-
"user_name": "mq-user",
78-
},
7968
})
8069

70+
terraformVars := map[string]interface{}{
71+
"existing_mq_capacity_crn": permanentResources["mq_capacity_crn"],
72+
"deployment_name": "da-upg-instance",
73+
"queue_manager_name": "da_upg",
74+
"queue_manager_display_name": "da-upg-display",
75+
"queue_manager_size": "xsmall",
76+
"resource_group_name": options.Prefix,
77+
"application_name": "app",
78+
"user_email": "mq-user@exmaple.com",
79+
"user_name": "mq-user",
80+
}
81+
82+
options.TerraformVars = terraformVars
83+
8184
// TODO: Once this test is on main, make this RunTestUpgrade
8285
output, err := options.RunTestConsistency()
8386
if !options.UpgradeTestSkipped {
@@ -86,8 +89,38 @@ func TestRunUpgradeExample(t *testing.T) {
8689
}
8790
}
8891

92+
// Run the DA in minimal configuration, valid logic for options
93+
// used in catalog pipeline
94+
func TestRunInstanceOnlyExample(t *testing.T) {
95+
// t.Parallel()
96+
97+
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
98+
Testing: t,
99+
TerraformDir: standardSolutionTerraformDir,
100+
Prefix: "mqi",
101+
Region: "us-east",
102+
})
103+
104+
terraformVars := map[string]interface{}{
105+
"existing_mq_capacity_crn": permanentResources["mq_capacity_crn"],
106+
"deployment_name": "instance-only",
107+
"queue_manager_name": "inst",
108+
"queue_manager_display_name": "instance-display",
109+
"queue_manager_size": "xsmall",
110+
"resource_group_name": options.Prefix,
111+
}
112+
113+
options.TerraformVars = terraformVars
114+
115+
output, err := options.RunTestConsistency()
116+
if !options.UpgradeTestSkipped {
117+
assert.Nil(t, err, "This should not have errored")
118+
assert.NotNil(t, output, "Expected some output")
119+
}
120+
}
121+
89122
func TestRunStandardSolutionSchematics(t *testing.T) {
90-
t.Parallel()
123+
// t.Parallel()
91124

92125
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
93126
Testing: t,

0 commit comments

Comments
 (0)