Skip to content

Commit 928af0e

Browse files
arya-girish-kArya Girish Kocofaigh
authored
feat: Add Project UI regex validation for the DA (#418)
* feat: Add UI regex validation * fix: Resolved precommit error * fix: Updated validation * fix: resolved typo error --------- Co-authored-by: Arya Girish K <[email protected]> Co-authored-by: Conall Ó Cofaigh <[email protected]>
1 parent 177dcaf commit 928af0e

File tree

3 files changed

+82
-12
lines changed

3 files changed

+82
-12
lines changed

ibm_catalog.json

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,14 @@
131131
},
132132
{
133133
"key": "prefix",
134-
"required": true
134+
"required": true,
135+
"value_constraints": [
136+
{
137+
"type": "regex",
138+
"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.",
139+
"value": "^$|^__NULL__$|^[a-z](?!.*--)(?:[a-z0-9-]{0,14}[a-z0-9])?$"
140+
}
141+
]
135142
},
136143
{
137144
"key": "service_plan",
@@ -247,10 +254,24 @@
247254
"key": "kms_encryption_enabled"
248255
},
249256
{
250-
"key": "existing_kms_instance_crn"
257+
"key": "existing_kms_instance_crn",
258+
"value_constraints": [
259+
{
260+
"type": "regex",
261+
"description": "The value provided for 'existing_kms_instance_crn' is not valid.",
262+
"value": "^__NULL__$|^crn:(.*:){3}(kms|hs-crypto):(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
263+
}
264+
]
251265
},
252266
{
253-
"key": "existing_secrets_manager_kms_key_crn"
267+
"key": "existing_secrets_manager_kms_key_crn",
268+
"value_constraints": [
269+
{
270+
"type": "regex",
271+
"description": "The value provided for 'existing_secrets_manager_kms_key_crn' is not valid.",
272+
"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-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$"
273+
}
274+
]
254275
},
255276
{
256277
"key": "skip_secrets_manager_kms_iam_auth_policy"
@@ -286,7 +307,14 @@
286307
"key": "event_notifications_reply_to_email"
287308
},
288309
{
289-
"key": "existing_event_notifications_instance_crn"
310+
"key": "existing_event_notifications_instance_crn",
311+
"value_constraints": [
312+
{
313+
"type": "regex",
314+
"description": "The value provided for 'existing_event_notifications_instance_crn' is not valid.",
315+
"value": "^__NULL__$|^crn:(.*:){3}event-notifications:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
316+
}
317+
]
290318
},
291319
{
292320
"key": "skip_secrets_manager_event_notifications_iam_auth_policy"
@@ -313,7 +341,14 @@
313341
}
314342
},
315343
{
316-
"key": "existing_secrets_manager_crn"
344+
"key": "existing_secrets_manager_crn",
345+
"value_constraints": [
346+
{
347+
"type": "regex",
348+
"description": "The value provided for 'existing_secrets_manager_crn' is not valid.",
349+
"value": "^__NULL__$|^crn:(.*:){3}secrets-manager:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
350+
}
351+
]
317352
}
318353
],
319354
"iam_permissions": [
@@ -638,7 +673,14 @@
638673
},
639674
{
640675
"key": "prefix",
641-
"required": true
676+
"required": true,
677+
"value_constraints": [
678+
{
679+
"type": "regex",
680+
"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.",
681+
"value": "^$|^__NULL__$|^[a-z](?!.*--)(?:[a-z0-9-]{0,14}[a-z0-9])?$"
682+
}
683+
]
642684
},
643685
{
644686
"key": "service_plan",
@@ -656,7 +698,14 @@
656698
},
657699
{
658700
"key": "existing_kms_instance_crn",
659-
"required": true
701+
"required": true,
702+
"value_constraints": [
703+
{
704+
"type": "regex",
705+
"description": "The value provided for 'existing_kms_instance_crn' is not valid.",
706+
"value": "^__NULL__$|^crn:(.*:){3}(kms|hs-crypto):(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
707+
}
708+
]
660709
},
661710
{
662711
"key": "existing_resource_group_name",
@@ -687,7 +736,14 @@
687736
"key": "skip_secrets_manager_iam_auth_policy"
688737
},
689738
{
690-
"key": "existing_secrets_manager_kms_key_crn"
739+
"key": "existing_secrets_manager_kms_key_crn",
740+
"value_constraints": [
741+
{
742+
"type": "regex",
743+
"description": "The value provided for 'existing_secrets_manager_kms_key_crn' is not valid.",
744+
"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-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$"
745+
}
746+
]
691747
},
692748
{
693749
"key": "skip_secrets_manager_kms_iam_auth_policy"
@@ -719,7 +775,14 @@
719775
"key": "event_notifications_reply_to_email"
720776
},
721777
{
722-
"key": "existing_event_notifications_instance_crn"
778+
"key": "existing_event_notifications_instance_crn",
779+
"value_constraints": [
780+
{
781+
"type": "regex",
782+
"description": "The value provided for 'existing_event_notifications_instance_crn' is not valid.",
783+
"value": "^__NULL__$|^crn:(.*:){3}event-notifications:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
784+
}
785+
]
723786
},
724787
{
725788
"key": "skip_secrets_manager_event_notifications_iam_auth_policy"
@@ -746,7 +809,14 @@
746809
}
747810
},
748811
{
749-
"key": "existing_secrets_manager_crn"
812+
"key": "existing_secrets_manager_crn",
813+
"value_constraints": [
814+
{
815+
"type": "regex",
816+
"description": "The value provided for 'existing_secrets_manager_crn' is not valid.",
817+
"value": "^__NULL__$|^crn:(.*:){3}secrets-manager:(.*:){2}[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}::$"
818+
}
819+
]
750820
}
751821
],
752822
"iam_permissions": [

solutions/fully-configurable/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ variable "region" {
3333

3434
variable "prefix" {
3535
type = string
36-
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: sm-0205. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
36+
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)."
3737

3838
validation {
3939
condition = var.prefix == null || var.prefix == "" ? true : alltrue([

solutions/security-enforced/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ variable "region" {
2222

2323
variable "prefix" {
2424
type = string
25-
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: sm-0205. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
25+
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)."
2626

2727
validation {
2828
condition = var.prefix == null || var.prefix == "" ? true : alltrue([

0 commit comments

Comments
 (0)