Skip to content

Commit

Permalink
Add map_configs variable (#7)
Browse files Browse the repository at this point in the history
* Add `map_configs` variable

* Add `map_configs` variable
  • Loading branch information
aknysh authored Jan 17, 2021
1 parent 816af55 commit 1afa46c
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ No provider.
| map\_config\_local\_base\_path | Base path to local YAML configuration files of map type | `string` | `""` | no |
| map\_config\_paths | Paths to YAML configuration files of map type | `list(string)` | `[]` | no |
| map\_config\_remote\_base\_path | Base path to remote YAML configuration files of map type | `string` | `""` | no |
| map\_configs | List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files | `any` | `[]` | no |
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
| parameters | Map of parameters for interpolation within the YAML config templates | `map(string)` | `{}` | no |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ No provider.
| map\_config\_local\_base\_path | Base path to local YAML configuration files of map type | `string` | `""` | no |
| map\_config\_paths | Paths to YAML configuration files of map type | `list(string)` | `[]` | no |
| map\_config\_remote\_base\_path | Base path to remote YAML configuration files of map type | `string` | `""` | no |
| map\_configs | List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files | `any` | `[]` | no |
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
| parameters | Map of parameters for interpolation within the YAML config templates | `map(string)` | `{}` | no |
Expand Down
4 changes: 4 additions & 0 deletions examples/complete/config/map-configs/map-config-3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
key3:
name: name3
param: param3
type: type3
32 changes: 32 additions & 0 deletions examples/complete/fixtures.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,35 @@ parameters = {
param1 = "1"
param2 = "2"
}

map_configs = [
{
key3 = {
name = "name3_override"
param = "param3_override"
},
key4 = {
name = "name4"
param = "param4"
type = "type4"
},
key5 = {
name = "name5"
param = ["param5a", "param5b"]
type = "type5"
}
},
{
key6 = {
name = "name6"
param = "param6"
type = "type6"
},
key1 = [
{
name = "name1_override"
param = "param1_override"
}
]
}
]
2 changes: 2 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module "yaml_config" {
list_config_remote_base_path = var.list_config_remote_base_path
list_config_paths = var.list_config_paths

map_configs = var.map_configs

parameters = var.parameters

context = module.this.context
Expand Down
6 changes: 6 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ variable "remote_config_selector" {
description = "String to detect local vs. remote config paths"
default = "://"
}

variable "map_configs" {
type = any
description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files"
default = []
}
2 changes: 2 additions & 0 deletions examples/imports-local/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module "yaml_config" {
list_config_remote_base_path = var.list_config_remote_base_path
list_config_paths = var.list_config_paths

map_configs = var.map_configs

parameters = var.parameters

context = module.this.context
Expand Down
6 changes: 6 additions & 0 deletions examples/imports-local/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ variable "remote_config_selector" {
description = "String to detect local vs. remote config paths"
default = "://"
}

variable "map_configs" {
type = any
description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files"
default = []
}
2 changes: 2 additions & 0 deletions examples/imports-remote/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module "yaml_config" {
list_config_remote_base_path = var.list_config_remote_base_path
list_config_paths = var.list_config_paths

map_configs = var.map_configs

parameters = var.parameters

context = module.this.context
Expand Down
6 changes: 6 additions & 0 deletions examples/imports-remote/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ variable "remote_config_selector" {
description = "String to detect local vs. remote config paths"
default = "://"
}

variable "map_configs" {
type = any
description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files"
default = []
}
27 changes: 15 additions & 12 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,21 @@ module "yaml_config_10" {
module "maps_deepmerge" {
source = "./modules/deepmerge"

maps = [
module.yaml_config_10.map_configs,
module.yaml_config_9.map_configs,
module.yaml_config_8.map_configs,
module.yaml_config_7.map_configs,
module.yaml_config_6.map_configs,
module.yaml_config_5.map_configs,
module.yaml_config_4.map_configs,
module.yaml_config_3.map_configs,
module.yaml_config_2.map_configs,
module.yaml_config_1.map_configs
]
maps = concat(
[
module.yaml_config_10.map_configs,
module.yaml_config_9.map_configs,
module.yaml_config_8.map_configs,
module.yaml_config_7.map_configs,
module.yaml_config_6.map_configs,
module.yaml_config_5.map_configs,
module.yaml_config_4.map_configs,
module.yaml_config_3.map_configs,
module.yaml_config_2.map_configs,
module.yaml_config_1.map_configs
],
var.map_configs
)
}

locals {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ variable "remote_config_selector" {
description = "String to detect local vs. remote config paths"
default = "://"
}

variable "map_configs" {
type = any
description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files"
default = []
}

0 comments on commit 1afa46c

Please sign in to comment.