Skip to content

Commit 68a78cb

Browse files
docs: Update DA Docs to include regex feature (#80)
1 parent 7b9c30e commit 68a78cb

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

docs/da-implementation-guidelines.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Below you will find some guidance on best practises that should be used when aut
88

99
All Deployable Architecture solutions should have an optional **`prefix`** input variable that complies with the following criteria:
1010
- Input should have no default value, but set `nullable = true` to allow user to pass `null` incase they do not wish to use a prefix. This would be for advanced users who may need full control over resource naming.
11-
- Add validation to the variable. See the below code snippet for the recommended validation to be added across all DAs. Ideally all DAs should have the same validation so the `prefix` value is accepted for all DAs for the case where it may be used for input mapping when configuring dependant (add-on) DAs.
11+
- Add validation to the variable. Validation should be added in both the terraform code and the ibm_catalog.json. See the below code snippets for the recommended validation to be added across all DAs. Ideally all DAs should have the same validation so the `prefix` value is accepted for all DAs for the case where it may be used for input mapping when configuring dependant (add-on) DAs.
1212
- Ensure to include the details of the required format in the variable description, an example value, and link to the helper doc just like what is shown in the code snippet below. This should be consistent across all DAs.
1313
- The prefix variable logic should be handled in a local variable so logic does not have repeated in the terraform code. For example:
1414
```hcl
@@ -26,15 +26,16 @@ All Deployable Architecture solutions should have an optional **`prefix`** input
2626
nullable = false
2727
}
2828
```
29-
3029
### Code snippet example
31-
The following code should be used consistently across all DAs (tweak the example value that is included in the description so it is relevant to the DA being created):
30+
The following code should be used consistently across all DAs.
31+
32+
#### variables.tf:
3233

3334
```hcl
3435
variable "prefix" {
3536
type = string
3637
nullable = true
37-
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-cos. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
38+
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)."
3839
3940
validation {
4041
# - null and empty string is allowed
@@ -58,3 +59,18 @@ variable "prefix" {
5859
}
5960
}
6061
```
62+
63+
#### ibm_catalog.json:
64+
65+
```json
66+
{
67+
"key": "prefix",
68+
"value_constraints": [
69+
{
70+
"type": "regex",
71+
"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.",
72+
"value": "^$|^__NULL__$|^[a-z](?!.*--)(?:[a-z0-9-]{0,14}[a-z0-9])?$"
73+
}
74+
]
75+
}
76+
```

0 commit comments

Comments
 (0)