Skip to content

Commit 60716dd

Browse files
authored
feat: Condense repo config file variables (#2)
1 parent 28b2ba0 commit 60716dd

File tree

4 files changed

+17
-31
lines changed

4 files changed

+17
-31
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ module "template" {
6464

6565
| Name | Description | Type | Default | Required |
6666
|------|-------------|------|---------|:--------:|
67-
| <a name="input_repo_config_file_format"></a> [repo\_config\_file\_format](#input\_repo\_config\_file\_format) | Format of the repo config file that will be generated. Possible values: yaml or json | `string` | `"yaml"` | no |
68-
| <a name="input_repo_config_file_generation_enabled"></a> [repo\_config\_file\_generation\_enabled](#input\_repo\_config\_file\_generation\_enabled) | Indicates wherever the config file should be generated | `bool` | `false` | no |
69-
| <a name="input_repo_config_file_name"></a> [repo\_config\_file\_name](#input\_repo\_config\_file\_name) | Name of the repo config file | `string` | `"repo_config.yaml"` | no |
70-
| <a name="input_repo_config_file_path"></a> [repo\_config\_file\_path](#input\_repo\_config\_file\_path) | Path where the repo config file should be generated | `string` | `"."` | no |
67+
| <a name="input_repo_config_file"></a> [repo\_config\_file](#input\_repo\_config\_file) | Configures config file generation if enabled | <pre>object({<br> enabled = optional(bool, false)<br> path = optional(string, ".")<br> name = optional(string, "repo_config.yaml")<br> format = optional(string, "yaml")<br> })</pre> | `{}` | no |
7168
| <a name="input_repos"></a> [repos](#input\_repos) | Map of repositories and their configs. Refer to https://www.runatlantis.io/docs/server-side-repo-config.html#example-server-side-repo | <pre>list(object({<br> id = optional(string, "/.*/")<br> branch = optional(string)<br> apply_requirements = optional(list(string))<br> allowed_overrides = optional(list(string))<br> allowed_workflows = optional(list(string))<br> allow_custom_workflows = optional(bool)<br> delete_source_branch_on_merge = optional(bool)<br> pre_workflow_hooks = optional(list(object({<br> run = string<br> })))<br> post_workflow_hooks = optional(list(object({<br> run = string<br> })))<br> workflow = optional(string)<br> ######### Helpers #########<br> allow_all_server_side_workflows = optional(bool, false)<br> terragrunt_atlantis_config = optional(object({<br> enabled = optional(bool, false)<br> output = optional(string, "atlantis.yaml")<br> automerge = optional(bool)<br> autoplan = optional(bool)<br> parallel = optional(bool)<br> cascade_dependencies = optional(bool)<br> filter = optional(string)<br> use_project_markers = optional(bool)<br> }), {})<br> }))</pre> | `[]` | no |
7269
| <a name="input_repos_common_config"></a> [repos\_common\_config](#input\_repos\_common\_config) | Common config that will be merged into each item of the repos list | <pre>object({<br> id = optional(string)<br> branch = optional(string)<br> apply_requirements = optional(list(string))<br> allowed_overrides = optional(list(string))<br> allowed_workflows = optional(list(string))<br> allow_custom_workflows = optional(bool)<br> delete_source_branch_on_merge = optional(bool)<br> pre_workflow_hooks = optional(list(object({<br> run = string<br> })))<br> post_workflow_hooks = optional(list(object({<br> run = string<br> })))<br> workflow = optional(string)<br> ######### Helpers #########<br> allow_all_server_side_workflows = optional(bool, false)<br> terragrunt_atlantis_config = optional(object({<br> enabled = optional(bool, false)<br> output = optional(string, "atlantis.yaml")<br> autoplan = optional(bool, false)<br> parallel = optional(bool, false)<br> filter = optional(string)<br> }), {})<br> })</pre> | `{}` | no |
7370
| <a name="input_use_predefined_workflows"></a> [use\_predefined\_workflows](#input\_use\_predefined\_workflows) | Indicates wherever predefined workflows should be added to the generated repo config file | `bool` | `true` | no |

examples/complete/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ module "repo_config" {
4444
}
4545
}
4646

47-
repo_config_file_generation_enabled = true
47+
repo_config_file = {
48+
enabled = true
49+
}
4850
}

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ locals {
5353
}
5454

5555
resource "local_file" "repo_config" {
56-
count = var.repo_config_file_generation_enabled ? 1 : 0
57-
content = (var.repo_config_file_format == "json"
56+
count = var.repo_config_file.enabled ? 1 : 0
57+
content = (var.repo_config_file.format == "json"
5858
? local.repo_config_json
5959
: local.repo_config_yaml
6060
)
61-
filename = format("%s/%s", var.repo_config_file_path, var.repo_config_file_name)
61+
filename = format("%s/%s", var.repo_config_file.path, var.repo_config_file.name)
6262
file_permission = "0644"
6363
}

variables.tf

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,18 @@ variable "use_predefined_workflows" {
8383
default = true
8484
}
8585

86-
variable "repo_config_file_generation_enabled" {
87-
description = "Indicates wherever the config file should be generated"
88-
type = bool
89-
default = false
90-
}
91-
92-
variable "repo_config_file_path" {
93-
description = "Path where the repo config file should be generated"
94-
type = string
95-
default = "."
96-
}
97-
98-
variable "repo_config_file_name" {
99-
description = "Name of the repo config file"
100-
type = string
101-
default = "repo_config.yaml"
102-
}
103-
104-
variable "repo_config_file_format" {
105-
description = "Format of the repo config file that will be generated. Possible values: yaml or json"
106-
type = string
107-
default = "yaml"
86+
variable "repo_config_file" {
87+
description = "Configures config file generation if enabled"
88+
type = object({
89+
enabled = optional(bool, false)
90+
path = optional(string, ".")
91+
name = optional(string, "repo_config.yaml")
92+
format = optional(string, "yaml")
93+
})
94+
default = {}
10895

10996
validation {
110-
condition = contains(["yaml", "json"], var.repo_config_file_format)
97+
condition = contains(["yaml", "json"], var.repo_config_file.format)
11198
error_message = "Invalid format provided. Allowed values: yaml, json"
11299
}
113100
}

0 commit comments

Comments
 (0)