Skip to content

Commit 547ebc4

Browse files
committed
fix: addressed PR comments
1 parent c10379c commit 547ebc4

File tree

5 files changed

+71
-60
lines changed

5 files changed

+71
-60
lines changed

ibm_catalog.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"key": "existing_secrets_manager_crn",
103103
"required": true
104104
},
105+
{
106+
"key": "sm_ibmcloud_api_key"
107+
},
105108
{
106109
"key": "eso_namespace"
107110
},

solutions/fully-configurable/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ module "crn_parser_sm" {
1717
}
1818

1919
locals {
20-
cluster_id = module.crn_parser_cluster.service_instance
21-
cluster_region = module.crn_parser_cluster.region
22-
sm_region = module.crn_parser_sm.region
23-
sm_guid = module.crn_parser_sm.service_instance
20+
cluster_id = module.crn_parser_cluster.service_instance
21+
cluster_region = module.crn_parser_cluster.region
22+
sm_region = module.crn_parser_sm.region
23+
sm_guid = module.crn_parser_sm.service_instance
24+
sm_ibmcloud_api_key = var.sm_ibmcloud_api_key == null ? var.ibmcloud_api_key : var.sm_ibmcloud_api_key
2425
}
2526

2627
data "ibm_container_cluster_config" "cluster_config" {

solutions/fully-configurable/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ provider "ibm" {
55
}
66

77
provider "ibm" {
8-
ibmcloud_api_key = var.ibmcloud_api_key
8+
ibmcloud_api_key = local.sm_ibmcloud_api_key
99
visibility = var.provider_visibility
1010
region = local.sm_region
1111
alias = "ibm-sm"

solutions/fully-configurable/variables.tf

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

11+
variable "sm_ibmcloud_api_key" {
12+
type = string
13+
description = "APIkey to authenticate on Secrets Manager instance. If null the ibmcloud_api_key will be used."
14+
}
15+
1116
variable "provider_visibility" {
1217
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)."
1318
type = string
@@ -311,36 +316,36 @@ variable "eso_secretsstores_configuration" {
311316
cluster_secrets_stores = map(object({
312317
namespace = string
313318
create_namespace = bool
314-
existing_serviceid_id = string
315-
serviceid_name = string
316-
serviceid_description = string
317-
existing_account_secrets_group_id = string
318-
account_secrets_group_name = string
319-
account_secrets_group_description = string
320-
trusted_profile_name = string # if both the trusted_profile_name and the serviceid_name/existing_serviceid_id are set, the trusted_profile_name will be used
321-
trusted_profile_description = string
322-
existing_service_secrets_group_id_list = list(string)
323-
service_secrets_groups_list = list(object({
319+
existing_serviceid_id = optional(string, null)
320+
serviceid_name = optional(string, null)
321+
serviceid_description = optional(string, null)
322+
existing_account_secrets_group_id = optional(string, null)
323+
account_secrets_group_name = optional(string, null)
324+
account_secrets_group_description = optional(string, null)
325+
trusted_profile_name = optional(string, null) # if both the trusted_profile_name and the serviceid_name/existing_serviceid_id are set, the trusted_profile_name will be used
326+
trusted_profile_description = optional(string, null)
327+
existing_service_secrets_group_id_list = optional(list(string), [])
328+
service_secrets_groups_list = optional(list(object({
324329
name = string
325330
description = string
326-
}))
331+
})), [])
327332
}))
328333
secrets_stores = map(object({
329334
create_namespace = bool
330-
namespace = string
331-
existing_serviceid_id = string
332-
serviceid_name = string
333-
serviceid_description = string
334-
existing_account_secrets_group_id = string
335-
account_secrets_group_name = string
336-
account_secrets_group_description = string
337-
trusted_profile_name = string # if both the trusted_profile_name and the serviceid_name/existing_serviceid_id are set, the trusted_profile_name will be used
338-
trusted_profile_description = string
339-
existing_service_secrets_group_id_list = list(string)
340-
service_secrets_groups_list = list(object({
335+
namespace = optional(string, null)
336+
existing_serviceid_id = optional(string, null)
337+
serviceid_name = optional(string, null)
338+
serviceid_description = optional(string, null)
339+
existing_account_secrets_group_id = optional(string, null)
340+
account_secrets_group_name = optional(string, null)
341+
account_secrets_group_description = optional(string, null)
342+
trusted_profile_name = optional(string, null) # if both the trusted_profile_name and the serviceid_name/existing_serviceid_id are set, the trusted_profile_name will be used
343+
trusted_profile_description = optional(string, null)
344+
existing_service_secrets_group_id_list = optional(list(string), [])
345+
service_secrets_groups_list = optional(list(object({
341346
name = string
342347
description = string
343-
}))
348+
})), [])
344349
}))
345350
})
346351
default = {

tests/pr_test.go

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ func getFullConfigSolutionTestVariables(mainOptions *testschematic.TestSchematic
625625
"cluster_secrets_stores": map[string]any{
626626

627627
"css-1": map[string]any{
628-
"namespace": "eso-namespace-cs1",
629-
"create_namespace": true,
630-
"existing_serviceid_id": "",
631-
"serviceid_name": "esoda-test-css-1-serviceid",
632-
"serviceid_description": "esoda-test-css-1-serviceid description",
633-
"existing_account_secrets_group_id": "",
628+
"namespace": "eso-namespace-cs1",
629+
"create_namespace": true,
630+
// "existing_serviceid_id": "",
631+
"serviceid_name": "esoda-test-css-1-serviceid",
632+
"serviceid_description": "esoda-test-css-1-serviceid description",
633+
// "existing_account_secrets_group_id": "",
634634
"account_secrets_group_name": "esoda-test-cs-accsg-1",
635635
"account_secrets_group_description": "esoda-test-cs-accsg-1 description",
636636
"trusted_profile_name": "",
@@ -648,16 +648,16 @@ func getFullConfigSolutionTestVariables(mainOptions *testschematic.TestSchematic
648648
},
649649
},
650650
"css-2": map[string]any{
651-
"namespace": "eso-namespace-cs2",
652-
"create_namespace": true,
653-
"existing_serviceid_id": "",
654-
"serviceid_name": "esoda-test-css-3-serviceid",
655-
"serviceid_description": "esoda-test-css-3-serviceid description",
656-
"existing_account_secrets_group_id": "",
657-
"account_secrets_group_name": "esoda-test-cs-accsg-3",
658-
"account_secrets_group_description": "esoda-test-cs-accsg-3 description",
659-
"trusted_profile_name": "",
660-
"trusted_profile_description": "",
651+
"namespace": "eso-namespace-cs2",
652+
"create_namespace": true,
653+
"existing_serviceid_id": "",
654+
"serviceid_name": "esoda-test-css-3-serviceid",
655+
"serviceid_description": "esoda-test-css-3-serviceid description",
656+
"existing_account_secrets_group_id": "",
657+
"account_secrets_group_name": "esoda-test-cs-accsg-3",
658+
"account_secrets_group_description": "esoda-test-cs-accsg-3 description",
659+
// "trusted_profile_name": "",
660+
// "trusted_profile_description": "",
661661
"existing_service_secrets_group_id_list": []string{},
662662
"service_secrets_groups_list": []map[string]any{
663663
{
@@ -674,16 +674,16 @@ func getFullConfigSolutionTestVariables(mainOptions *testschematic.TestSchematic
674674
"secrets_stores": map[string]any{
675675

676676
"ss-1": map[string]any{
677-
"namespace": "eso-namespace-ss1",
678-
"create_namespace": true,
679-
"existing_serviceid_id": "",
680-
"serviceid_name": "esoda-test-ss-1-serviceid",
681-
"serviceid_description": "esoda-test-ss-1-serviceid description",
682-
"existing_account_secrets_group_id": "",
683-
"account_secrets_group_name": "esoda-test-ss-accsg-1",
684-
"account_secrets_group_description": "esoda-test-ss-accsg-1 description",
685-
"trusted_profile_name": "",
686-
"trusted_profile_description": "",
677+
"namespace": "eso-namespace-ss1",
678+
"create_namespace": true,
679+
"existing_serviceid_id": "",
680+
"serviceid_name": "esoda-test-ss-1-serviceid",
681+
"serviceid_description": "esoda-test-ss-1-serviceid description",
682+
"existing_account_secrets_group_id": "",
683+
"account_secrets_group_name": "esoda-test-ss-accsg-1",
684+
"account_secrets_group_description": "esoda-test-ss-accsg-1 description",
685+
// "trusted_profile_name": "",
686+
// "trusted_profile_description": "",
687687
"existing_service_secrets_group_id_list": []string{},
688688
"service_secrets_groups_list": []map[string]any{
689689
{
@@ -697,12 +697,12 @@ func getFullConfigSolutionTestVariables(mainOptions *testschematic.TestSchematic
697697
},
698698
},
699699
"ss-2": map[string]any{
700-
"namespace": "eso-namespace-ss2",
701-
"create_namespace": true,
702-
"existing_serviceid_id": "",
703-
"serviceid_name": "esoda-test-ss-2-serviceid",
704-
"serviceid_description": "esoda-test-ss-2-serviceid description",
705-
"existing_account_secrets_group_id": "",
700+
"namespace": "eso-namespace-ss2",
701+
"create_namespace": true,
702+
// "existing_serviceid_id": "",
703+
"serviceid_name": "esoda-test-ss-2-serviceid",
704+
"serviceid_description": "esoda-test-ss-2-serviceid description",
705+
// "existing_account_secrets_group_id": "",
706706
"account_secrets_group_name": "esoda-test-ss-accsg-2",
707707
"account_secrets_group_description": "esoda-test-ss-accsg-2 description",
708708
"trusted_profile_name": "",
@@ -724,6 +724,8 @@ func getFullConfigSolutionTestVariables(mainOptions *testschematic.TestSchematic
724724

725725
logger.Log(mainOptions.Testing, "setupSolutionSchematicOptions - Using mainOptions.Prefix: ", mainOptions.Prefix)
726726

727+
logger.Log(mainOptions.Testing, "TEST TO REMOVE: ", mainOptions.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"])
728+
727729
vars := []testschematic.TestSchematicTerraformVar{
728730
{Name: "ibmcloud_api_key", Value: mainOptions.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
729731
{Name: "prefix", Value: mainOptions.Prefix, DataType: "string"},

0 commit comments

Comments
 (0)