Skip to content

Commit 77af7aa

Browse files
feat: exposed the ability to set the provider_visibility in the DA [Learn more](https://registry.terraform.io/providers/IBM-Cloud/IBM/latest/docs#visibility-1) (#132)
1 parent 7fd2da3 commit 77af7aa

File tree

7 files changed

+194
-0
lines changed

7 files changed

+194
-0
lines changed

cra-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CRA_TARGETS:
77
CRA_ENVIRONMENT_VARIABLES:
88
TF_VAR_acme_letsencrypt_private_key: "DUMMY VALUE FOR CRA"
99
TF_VAR_cis_id: "crn:v1:bluemix:public:internet-svcs:global:a/abac0df06b644a9cabc6e44f55b3880e:59aa1a88-ac47-45e4-bd96-2bc778d26ca7::"
10+
TF_VAR_provider_visibility: "public"
1011
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.
1112
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
1213
# CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.

ibm_catalog.json

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,127 @@
118118
"description": "This deployable architecture creates IBM Cloud Code Engine and configures the project, apps, domain mappings, secrets, configmaps, and service bindings."
119119
}
120120
]
121+
},
122+
"configuration":[
123+
{
124+
"key": "ibmcloud_api_key"
125+
},
126+
{
127+
"key": "provider_visibility",
128+
"options": [
129+
{
130+
"displayname": "private",
131+
"value": "private"
132+
},
133+
{
134+
"displayname": "public",
135+
"value": "public"
136+
},
137+
{
138+
"displayname": "public-and-private",
139+
"value": "public-and-private"
140+
}
141+
]
142+
},
143+
{
144+
"key": "existing_resource_group"
145+
},
146+
{
147+
"key": "resource_group_name"
148+
},
149+
{
150+
"key": "region",
151+
"type": "string",
152+
"custom_config": {
153+
"type": "region",
154+
"grouping": "deployment",
155+
"original_grouping": "deployment",
156+
"config_constraints": {
157+
"showKinds": [
158+
"region"
159+
]
160+
}
161+
}
162+
},
163+
{
164+
"key": "project_name"
165+
},
166+
{
167+
"key": "existing_project_id"
168+
},
169+
{
170+
"key": "app_name"
171+
},
172+
{
173+
"key": "image_reference"
174+
},
175+
{
176+
"key": "image_secret"
177+
},
178+
{
179+
"key": "run_env_variables"
180+
},
181+
{
182+
"key": "run_volume_mounts"
183+
},
184+
{
185+
"key":"image_port"
186+
},
187+
{
188+
"key":"managed_domain_mappings"
189+
},
190+
{
191+
"key":"run_arguments"
192+
},
193+
{
194+
"key":"run_as_user"
195+
},
196+
{
197+
"key":"run_commands"
198+
},
199+
{
200+
"key":"run_service_account"
201+
},
202+
{
203+
"key":"scale_concurrency"
204+
},
205+
{
206+
"key":"scale_concurrency_target"
207+
},
208+
{
209+
"key":"scale_cpu_limit"
210+
},
211+
{
212+
"key":"scale_ephemeral_storage_limit"
213+
},
214+
{
215+
"key":"scale_initial_instances"
216+
},
217+
{
218+
"key":"scale_max_instances"
219+
},
220+
{
221+
"key":"scale_memory_limit"
222+
},
223+
{
224+
"key":"scale_min_instances"
225+
},
226+
{
227+
"key":"scale_request_timeout"
228+
},
229+
{
230+
"key":"config_maps"
231+
},
232+
{
233+
"key":"secrets"
234+
},
235+
{
236+
"key":"domain_mappings"
237+
},
238+
{
239+
"key":"bindings"
121240
}
241+
]
122242
},
123243
{
124244
"label": "New Code Engine projects",
@@ -157,7 +277,55 @@
157277
"description": "This deployable architecture creates IBM Cloud Code Engine projects"
158278
}
159279
]
280+
},
281+
"configuration":[
282+
{
283+
"key": "ibmcloud_api_key"
284+
},
285+
{
286+
"key": "provider_visibility",
287+
"options": [
288+
{
289+
"displayname": "private",
290+
"value": "private"
291+
},
292+
{
293+
"displayname": "public",
294+
"value": "public"
295+
},
296+
{
297+
"displayname": "public-and-private",
298+
"value": "public-and-private"
299+
}
300+
]
301+
},
302+
{
303+
"key": "prefix"
304+
},
305+
{
306+
"key": "existing_resource_group"
307+
},
308+
{
309+
"key": "resource_group_name"
310+
},
311+
{
312+
"key": "region",
313+
"type": "string",
314+
"custom_config": {
315+
"type": "region",
316+
"grouping": "deployment",
317+
"original_grouping": "deployment",
318+
"config_constraints": {
319+
"showKinds": [
320+
"region"
321+
]
322+
}
323+
}
324+
},
325+
{
326+
"key": "project_names"
160327
}
328+
]
161329
}
162330
]
163331
}

solutions/apps/provider.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
provider "ibm" {
66
ibmcloud_api_key = var.ibmcloud_api_key
77
region = var.region
8+
visibility = var.provider_visibility
89
}

solutions/apps/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ variable "ibmcloud_api_key" {
88
sensitive = true
99
}
1010

11+
variable "provider_visibility" {
12+
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
13+
type = string
14+
default = "private"
15+
16+
validation {
17+
condition = contains(["public", "private", "public-and-private"], var.provider_visibility)
18+
error_message = "Invalid visibility option. Allowed values are 'public', 'private', or 'public-and-private'."
19+
}
20+
}
21+
1122
variable "region" {
1223
type = string
1324
description = "The region in which to provision all resources created by this solution."

solutions/projects/provider.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
provider "ibm" {
66
ibmcloud_api_key = var.ibmcloud_api_key
77
region = var.region
8+
visibility = var.provider_visibility
89
}

solutions/projects/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ variable "ibmcloud_api_key" {
77
description = "The IBM Cloud API key."
88
sensitive = true
99
}
10+
variable "provider_visibility" {
11+
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
12+
type = string
13+
default = "private"
1014

15+
validation {
16+
condition = contains(["public", "private", "public-and-private"], var.provider_visibility)
17+
error_message = "Invalid visibility option. Allowed values are 'public', 'private', or 'public-and-private'."
18+
}
19+
}
1120
variable "prefix" {
1221
type = string
1322
description = "Prefix to added to all projects created by this solution."

tests/pr_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func TestRunUpgradeAppSolution(t *testing.T) {
163163
"existing_resource_group": true,
164164
"app_name": options.Prefix + "-app",
165165
"image_reference": "icr.io/codeengine/helloworld",
166+
"provider_visibility": "public",
166167
"secrets": "{" + options.Prefix + "-secret:{format:\"generic\", data:{ key_1 : \"value_1\" }}}", // pragma: allowlist secret
167168
"config_maps": "{" + options.Prefix + "-cm:{data:{ key_1 : \"value_1\" }}}",
168169
"project_name": options.Prefix + "-pro",
@@ -187,6 +188,7 @@ func TestUpgradeCEProjectsDA(t *testing.T) {
187188
options.TerraformVars = map[string]interface{}{
188189
"resource_group_name": resourceGroup,
189190
"existing_resource_group": true,
191+
"provider_visibility": "public",
190192
"prefix": options.Prefix,
191193
"project_names": "[\"test-1\", \"test-2\", \"test-3\", \"test-4\", \"test-5\"]",
192194
}
@@ -212,6 +214,7 @@ func TestDeployCEProjectsDA(t *testing.T) {
212214
"resource_group_name": resourceGroup,
213215
"existing_resource_group": true,
214216
"prefix": options.Prefix,
217+
"provider_visibility": "public",
215218
"project_names": "[\"test-1\", \"test-2\", \"test-3\", \"test-4\", \"test-5\"]",
216219
}
217220

0 commit comments

Comments
 (0)