Skip to content

Commit ae5c1ed

Browse files
authored
Update to null-label 0.24.1 (#66)
1 parent 33e3be5 commit ae5c1ed

File tree

7 files changed

+122
-49
lines changed

7 files changed

+122
-49
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
# Cloud Posse must review any changes to standard context definition,
1717
# but some changes can be rubber-stamped.
18-
**/context.tf @cloudposse/engineering @cloudposse/approvers
19-
README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
20-
docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
18+
**/*.tf @cloudposse/engineering @cloudposse/approvers
19+
README.yaml @cloudposse/engineering @cloudposse/approvers
20+
README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
21+
docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
2122

2223
# Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration
2324
.github/mergify.yml @cloudposse/admins

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Available targets:
208208
209209
| Name | Version |
210210
|------|---------|
211-
| terraform | >= 0.12.26 |
211+
| terraform | >= 0.13.0 |
212212
| aws | >= 2.0 |
213213
| local | >= 1.2 |
214214
| null | >= 2.0 |
@@ -237,7 +237,7 @@ Available targets:
237237
| buildspec | Declaration to use for building the project. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `""` | no |
238238
| cache\_type | The type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO\_CACHE, LOCAL, and S3. Defaults to S3. If cache\_type is S3, it will create an S3 bucket for storing codebuild cache inside | `string` | `"S3"` | no |
239239
| codestar\_connection\_arn | CodeStar connection ARN required for Bitbucket integration with CodePipeline | `string` | `""` | no |
240-
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
240+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
241241
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
242242
| ecs\_cluster\_name | ECS Cluster Name | `string` | n/a | yes |
243243
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
@@ -246,10 +246,12 @@ Available targets:
246246
| github\_oauth\_token | GitHub OAuth Token with permissions to access private repositories | `string` | `""` | no |
247247
| github\_webhook\_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/) | `list(string)` | <pre>[<br> "push"<br>]</pre> | no |
248248
| github\_webhooks\_token | GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | `string` | `""` | no |
249-
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
249+
| id\_length\_limit | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
250250
| image\_repo\_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | n/a | yes |
251251
| image\_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | `"latest"` | no |
252+
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
252253
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
254+
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Default value: `lower`. | `string` | `null` | no |
253255
| local\_cache\_modes | Specifies settings that AWS CodeBuild uses to store and reuse build dependencies. Valid values: LOCAL\_SOURCE\_CACHE, LOCAL\_DOCKER\_LAYER\_CACHE, and LOCAL\_CUSTOM\_CACHE | `list(string)` | `[]` | no |
254256
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
255257
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |

context.tf

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
module "this" {
2222
source = "cloudposse/label/null"
23-
version = "0.22.1" // requires Terraform >= 0.12.26
23+
version = "0.24.1" # requires Terraform >= 0.13.0
2424

2525
enabled = var.enabled
2626
namespace = var.namespace
@@ -34,27 +34,16 @@ module "this" {
3434
label_order = var.label_order
3535
regex_replace_chars = var.regex_replace_chars
3636
id_length_limit = var.id_length_limit
37+
label_key_case = var.label_key_case
38+
label_value_case = var.label_value_case
3739

3840
context = var.context
3941
}
4042

4143
# Copy contents of cloudposse/terraform-null-label/variables.tf here
4244

4345
variable "context" {
44-
type = object({
45-
enabled = bool
46-
namespace = string
47-
environment = string
48-
stage = string
49-
name = string
50-
delimiter = string
51-
attributes = list(string)
52-
tags = map(string)
53-
additional_tag_map = map(string)
54-
regex_replace_chars = string
55-
label_order = list(string)
56-
id_length_limit = number
57-
})
46+
type = any
5847
default = {
5948
enabled = true
6049
namespace = null
@@ -68,6 +57,8 @@ variable "context" {
6857
regex_replace_chars = null
6958
label_order = []
7059
id_length_limit = null
60+
label_key_case = null
61+
label_value_case = null
7162
}
7263
description = <<-EOT
7364
Single object for setting entire context at once.
@@ -76,6 +67,16 @@ variable "context" {
7667
Individual variable settings (non-null) override settings in context object,
7768
except for attributes, tags, and additional_tag_map, which are merged.
7869
EOT
70+
71+
validation {
72+
condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
73+
error_message = "Allowed values: `lower`, `title`, `upper`."
74+
}
75+
76+
validation {
77+
condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
78+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
79+
}
7980
}
8081

8182
variable "enabled" {
@@ -158,11 +159,44 @@ variable "id_length_limit" {
158159
type = number
159160
default = null
160161
description = <<-EOT
161-
Limit `id` to this many characters.
162+
Limit `id` to this many characters (minimum 6).
162163
Set to `0` for unlimited length.
163164
Set to `null` for default, which is `0`.
164165
Does not affect `id_full`.
165166
EOT
167+
validation {
168+
condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
169+
error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
170+
}
171+
}
172+
173+
variable "label_key_case" {
174+
type = string
175+
default = null
176+
description = <<-EOT
177+
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
178+
Possible values: `lower`, `title`, `upper`.
179+
Default value: `title`.
180+
EOT
181+
182+
validation {
183+
condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
184+
error_message = "Allowed values: `lower`, `title`, `upper`."
185+
}
166186
}
167187

188+
variable "label_value_case" {
189+
type = string
190+
default = null
191+
description = <<-EOT
192+
The letter case of output label values (also used in `tags` and `id`).
193+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
194+
Default value: `lower`.
195+
EOT
196+
197+
validation {
198+
condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
199+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
200+
}
201+
}
168202
#### End of copy of cloudposse/terraform-null-label/variables.tf

docs/terraform.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| Name | Version |
55
|------|---------|
6-
| terraform | >= 0.12.26 |
6+
| terraform | >= 0.13.0 |
77
| aws | >= 2.0 |
88
| local | >= 1.2 |
99
| null | >= 2.0 |
@@ -32,7 +32,7 @@
3232
| buildspec | Declaration to use for building the project. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) | `string` | `""` | no |
3333
| cache\_type | The type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO\_CACHE, LOCAL, and S3. Defaults to S3. If cache\_type is S3, it will create an S3 bucket for storing codebuild cache inside | `string` | `"S3"` | no |
3434
| codestar\_connection\_arn | CodeStar connection ARN required for Bitbucket integration with CodePipeline | `string` | `""` | no |
35-
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
35+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
3636
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
3737
| ecs\_cluster\_name | ECS Cluster Name | `string` | n/a | yes |
3838
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
@@ -41,10 +41,12 @@
4141
| github\_oauth\_token | GitHub OAuth Token with permissions to access private repositories | `string` | `""` | no |
4242
| github\_webhook\_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/) | `list(string)` | <pre>[<br> "push"<br>]</pre> | no |
4343
| github\_webhooks\_token | GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | `string` | `""` | no |
44-
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
44+
| id\_length\_limit | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
4545
| image\_repo\_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | n/a | yes |
4646
| image\_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | `string` | `"latest"` | no |
47+
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
4748
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
49+
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Default value: `lower`. | `string` | `null` | no |
4850
| local\_cache\_modes | Specifies settings that AWS CodeBuild uses to store and reuse build dependencies. Valid values: LOCAL\_SOURCE\_CACHE, LOCAL\_DOCKER\_LAYER\_CACHE, and LOCAL\_CUSTOM\_CACHE | `list(string)` | `[]` | no |
4951
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
5052
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |

examples/complete/context.tf

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
module "this" {
2222
source = "cloudposse/label/null"
23-
version = "0.22.1" // requires Terraform >= 0.12.26
23+
version = "0.24.1" # requires Terraform >= 0.13.0
2424

2525
enabled = var.enabled
2626
namespace = var.namespace
@@ -34,27 +34,16 @@ module "this" {
3434
label_order = var.label_order
3535
regex_replace_chars = var.regex_replace_chars
3636
id_length_limit = var.id_length_limit
37+
label_key_case = var.label_key_case
38+
label_value_case = var.label_value_case
3739

3840
context = var.context
3941
}
4042

4143
# Copy contents of cloudposse/terraform-null-label/variables.tf here
4244

4345
variable "context" {
44-
type = object({
45-
enabled = bool
46-
namespace = string
47-
environment = string
48-
stage = string
49-
name = string
50-
delimiter = string
51-
attributes = list(string)
52-
tags = map(string)
53-
additional_tag_map = map(string)
54-
regex_replace_chars = string
55-
label_order = list(string)
56-
id_length_limit = number
57-
})
46+
type = any
5847
default = {
5948
enabled = true
6049
namespace = null
@@ -68,6 +57,8 @@ variable "context" {
6857
regex_replace_chars = null
6958
label_order = []
7059
id_length_limit = null
60+
label_key_case = null
61+
label_value_case = null
7162
}
7263
description = <<-EOT
7364
Single object for setting entire context at once.
@@ -76,6 +67,16 @@ variable "context" {
7667
Individual variable settings (non-null) override settings in context object,
7768
except for attributes, tags, and additional_tag_map, which are merged.
7869
EOT
70+
71+
validation {
72+
condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
73+
error_message = "Allowed values: `lower`, `title`, `upper`."
74+
}
75+
76+
validation {
77+
condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
78+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
79+
}
7980
}
8081

8182
variable "enabled" {
@@ -158,11 +159,44 @@ variable "id_length_limit" {
158159
type = number
159160
default = null
160161
description = <<-EOT
161-
Limit `id` to this many characters.
162+
Limit `id` to this many characters (minimum 6).
162163
Set to `0` for unlimited length.
163164
Set to `null` for default, which is `0`.
164165
Does not affect `id_full`.
165166
EOT
167+
validation {
168+
condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
169+
error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
170+
}
171+
}
172+
173+
variable "label_key_case" {
174+
type = string
175+
default = null
176+
description = <<-EOT
177+
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
178+
Possible values: `lower`, `title`, `upper`.
179+
Default value: `title`.
180+
EOT
181+
182+
validation {
183+
condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
184+
error_message = "Allowed values: `lower`, `title`, `upper`."
185+
}
166186
}
167187

188+
variable "label_value_case" {
189+
type = string
190+
default = null
191+
description = <<-EOT
192+
The letter case of output label values (also used in `tags` and `id`).
193+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
194+
Default value: `lower`.
195+
EOT
196+
197+
validation {
198+
condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
199+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
200+
}
201+
}
168202
#### End of copy of cloudposse/terraform-null-label/variables.tf

0 commit comments

Comments
 (0)