Skip to content

Commit d4b56c5

Browse files
authored
feat: add variable and option to not manage all addons (#296)
1 parent ca12ea5 commit d4b56c5

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-07-08T10:32:00Z",
6+
"generated_at": "2023-07-09T10:32:00Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ Optionally, you need the following permissions to attach Access Management tags
199199
| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | APIkey that's associated with the account to use, set via environment variable TF\_VAR\_ibmcloud\_api\_key | `string` | n/a | yes |
200200
| <a name="input_ignore_worker_pool_size_changes"></a> [ignore\_worker\_pool\_size\_changes](#input\_ignore\_worker\_pool\_size\_changes) | Enable if using worker autoscaling. Stops Terraform managing worker count | `bool` | `false` | no |
201201
| <a name="input_kms_config"></a> [kms\_config](#input\_kms\_config) | Use to attach a Key Protect instance to the cluster | <pre>object({<br> crk_id = string<br> instance_id = string<br> private_endpoint = optional(bool, true) # defaults to true<br> })</pre> | `null` | no |
202+
| <a name="input_manage_all_addons"></a> [manage\_all\_addons](#input\_manage\_all\_addons) | Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module will destroy any addons that were installed by other sources. | `bool` | `false` | no |
202203
| <a name="input_ocp_entitlement"></a> [ocp\_entitlement](#input\_ocp\_entitlement) | Value that is applied to the entitlements for OCP cluster provisioning | `string` | `"cloud_pak"` | no |
203204
| <a name="input_ocp_version"></a> [ocp\_version](#input\_ocp\_version) | The version of the OpenShift cluster that should be provisioned (format 4.x). This is only used during initial cluster provisioning, but ignored for future updates. Supports passing the string 'latest' (current latest available version) or 'default' (current IKS default recommended version). If no value is passed, it will default to 'default'. | `string` | `null` | no |
204205
| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where the cluster will be provisioned. | `string` | n/a | yes |

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ resource "ibm_container_addons" "addons" {
380380
cluster = local.cluster_id
381381
resource_group_id = var.resource_group_id
382382

383+
# setting to false means we do not want Terraform to manage addons that are managed elsewhere
384+
manage_all_addons = var.manage_all_addons
385+
383386
dynamic "addons" {
384387
for_each = local.addons
385388
content {

tests/pr_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ func TestFSCloudExample(t *testing.T) {
103103
},
104104
})
105105

106+
// If "jp-osa" was the best region selected, default to us-south instead.
107+
// "jp-osa" is currently not allowing hs-crypto be used for encrypting buckets in that region.
108+
currentRegion, ok := options.TerraformVars["region"]
109+
if ok && currentRegion == "jp-osa" {
110+
options.TerraformVars["region"] = "us-south"
111+
}
112+
106113
output, err := options.RunTestConsistency()
107114

108115
assert.Nil(t, err, "This should not have errored")

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ variable "addons" {
214214
default = null
215215
}
216216

217+
variable "manage_all_addons" {
218+
type = bool
219+
default = false
220+
nullable = false # null values are set to default value
221+
description = "Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module will destroy any addons that were installed by other sources."
222+
}
223+
217224
variable "cluster_config_endpoint_type" {
218225
description = "Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster."
219226
type = string

0 commit comments

Comments
 (0)