Skip to content

Commit 4d8babc

Browse files
iamar7Md Anam Raihan
andauthored
feat: Add Project UI regex validation for the DA (#137)
* feat: added regex validation to DA inputs * update constraints * update description and grammer --------- Co-authored-by: Md Anam Raihan <[email protected]>
1 parent 00ce39f commit 4d8babc

File tree

3 files changed

+90
-13
lines changed

3 files changed

+90
-13
lines changed

ibm_catalog.json

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@
6363
},
6464
{
6565
"key": "prefix",
66-
"required": true
66+
"required": true,
67+
"value_constraints": [
68+
{
69+
"type": "regex",
70+
"description": "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--'). It should not exceed 16 characters.",
71+
"value": "^$|^__NULL__$|^[a-z](?!.*--)(?:[a-z0-9-]{0,14}[a-z0-9])?$"
72+
}
73+
]
6774
},
6875
{
6976
"key": "region",
@@ -113,7 +120,14 @@
113120
},
114121
{
115122
"key": "existing_cos_instance_crn",
116-
"required": true
123+
"required": true,
124+
"value_constraints": [
125+
{
126+
"type": "regex",
127+
"description": "The value provided for 'existing_cos_instance_crn' is not valid.",
128+
"value": "^crn:(.*:){3}cloud-object-storage:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
129+
}
130+
]
117131
},
118132
{
119133
"key": "existing_resource_group_name",
@@ -248,10 +262,24 @@
248262
"key": "kms_encryption_enabled_buckets"
249263
},
250264
{
251-
"key": "existing_kms_instance_crn"
265+
"key": "existing_kms_instance_crn",
266+
"value_constraints": [
267+
{
268+
"type": "regex",
269+
"description": "The value provided for 'existing_kms_instance_crn' is not valid.",
270+
"value": "^__NULL__$|^crn:(.*:){3}(kms|hs-crypto):(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
271+
}
272+
]
252273
},
253274
{
254-
"key": "existing_kms_key_crn"
275+
"key": "existing_kms_key_crn",
276+
"value_constraints": [
277+
{
278+
"type": "regex",
279+
"description": "The value provided for 'existing_kms_key_crn' is not valid.",
280+
"value": "^__NULL__$|^crn:(.*:){3}(kms|hs-crypto):(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}:key:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
281+
}
282+
]
255283
},
256284
{
257285
"key": "kms_endpoint_type",
@@ -298,10 +326,24 @@
298326
}
299327
},
300328
{
301-
"key": "existing_cloud_logs_crn"
329+
"key": "existing_cloud_logs_crn",
330+
"value_constraints": [
331+
{
332+
"type": "regex",
333+
"description": "The value provided for 'existing_cloud_logs_crn' is not valid.",
334+
"value": "^__NULL__$|^crn:(.*:){3}logs:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
335+
}
336+
]
302337
},
303338
{
304-
"key": "existing_monitoring_crn"
339+
"key": "existing_monitoring_crn",
340+
"value_constraints": [
341+
{
342+
"type": "regex",
343+
"description": "The value provided for 'existing_monitoring_crn' is not valid.",
344+
"value": "^__NULL__$|^crn:(.*:){3}sysdig-monitor:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
345+
}
346+
]
305347
},
306348
{
307349
"key": "cloud_logs_cbr_rules",
@@ -551,7 +593,14 @@
551593
},
552594
{
553595
"key": "prefix",
554-
"required": true
596+
"required": true,
597+
"value_constraints": [
598+
{
599+
"type": "regex",
600+
"description": "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--'). It should not exceed 16 characters.",
601+
"value": "^$|^__NULL__$|^[a-z](?!.*--)(?:[a-z0-9-]{0,14}[a-z0-9])?$"
602+
}
603+
]
555604
},
556605
{
557606
"key": "region",
@@ -601,11 +650,25 @@
601650
},
602651
{
603652
"key": "existing_cos_instance_crn",
604-
"required": true
653+
"required": true,
654+
"value_constraints": [
655+
{
656+
"type": "regex",
657+
"description": "The value provided for 'existing_cos_instance_crn' is not valid.",
658+
"value": "^crn:(.*:){3}cloud-object-storage:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
659+
}
660+
]
605661
},
606662
{
607663
"key": "existing_kms_instance_crn",
608-
"required": true
664+
"required": true,
665+
"value_constraints": [
666+
{
667+
"type": "regex",
668+
"description": "The value provided for 'existing_kms_instance_crn' is not valid.",
669+
"value": "^crn:(.*:){3}(kms|hs-crypto):(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
670+
}
671+
]
609672
},
610673
{
611674
"key": "existing_resource_group_name",
@@ -712,7 +775,14 @@
712775
"key": "skip_cos_kms_iam_auth_policy"
713776
},
714777
{
715-
"key": "existing_kms_key_crn"
778+
"key": "existing_kms_key_crn",
779+
"value_constraints": [
780+
{
781+
"type": "regex",
782+
"description": "The value provided for 'existing_kms_key_crn' is not valid.",
783+
"value": "^__NULL__$|^crn:(.*:){3}(kms|hs-crypto):(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}:key:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
784+
}
785+
]
716786
},
717787
{
718788
"key": "cloud_logs_cos_key_ring_name"
@@ -745,7 +815,14 @@
745815
}
746816
},
747817
{
748-
"key": "existing_monitoring_crn"
818+
"key": "existing_monitoring_crn",
819+
"value_constraints": [
820+
{
821+
"type": "regex",
822+
"description": "The value provided for 'existing_monitoring_crn' is not valid.",
823+
"value": "^__NULL__$|^crn:(.*:){3}sysdig-monitor:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
824+
}
825+
]
749826
},
750827
{
751828
"key": "cloud_logs_cbr_rules",

solutions/fully-configurable/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "existing_resource_group_name" {
1717
variable "prefix" {
1818
type = string
1919
nullable = true
20-
description = "The prefix to be added to all resources created by this solution. To skip using a prefix, set this value to null or an empty string. The prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It should not exceed 16 characters, must not end with a hyphen('-'), and can not contain consecutive hyphens ('--'). Example: prod-0205-icl. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
20+
description = "The prefix to add to all resources that this solution creates (e.g `prod`, `test`, `dev`). To skip using a prefix, set this value to null or an empty string. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
2121

2222
validation {
2323
# - null and empty string is allowed

solutions/security-enforced/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ variable "existing_resource_group_name" {
1616

1717
variable "prefix" {
1818
type = string
19-
description = "The prefix to add to all resources that this solution creates. Prefix must begin with a lowercase letter, contain only lowercase letters, numbers, and - characters. Prefixes must end with a lowercase letter or number and be 16 or fewer characters. It also cannot have a `--`. To not use any prefix value, you can set this value to `null` or an empty string."
19+
description = "The prefix to add to all resources that this solution creates (e.g `prod`, `test`, `dev`). To skip using a prefix, set this value to null or an empty string. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
2020
nullable = true
2121
validation {
2222
condition = (var.prefix == null ? true :

0 commit comments

Comments
 (0)