-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
103 lines (100 loc) · 3.48 KB
/
variables.tf
File metadata and controls
103 lines (100 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
variable "build_definition" {
type = any
default = {}
description = "Resource definition, default settings are defined within locals and merged with var settings. For more information look at [Outputs](#Outputs)."
}
locals {
default = {
// resource definition
build_definition = {
name = ""
path = null
agent_pool_name = null
variable_groups = null
repository = {
branch_name = "refs/heads/main" // defined default
service_connection_id = null
github_enterprise_url = null
report_build_status = null
}
ci_trigger = {
use_yaml = null
override = {
batch = null
polling_interval = null
polling_job_id = null
branch_filter = {
include = null
exclude = null
}
path_filter = {
include = null
exclude = null
}
}
}
pull_request_trigger = {
use_yaml = null
initial_branch = null
override = {
auto_cancel = null
branch_filter = {
include = null
exclude = null
}
path_filter = {
include = null
exclude = null
}
}
forks = {}
}
variable = {
name = ""
value = null
secret_value = null
is_secret = null
allow_override = null
}
}
}
// compare and merge custom and default values
build_definition_values = {
for build_definition in keys(var.build_definition) :
build_definition => merge(local.default.build_definition, var.build_definition[build_definition])
}
// deep merge of all custom and default values
build_definition = {
for build_definition in keys(var.build_definition) :
build_definition => merge(
local.build_definition_values[build_definition],
{
for config in ["repository"] :
config => merge(local.default.build_definition[config], local.build_definition_values[build_definition][config])
},
{
for config in ["ci_trigger", "pull_request_trigger"] :
config => lookup(var.build_definition[build_definition], config, {}) == {} ? null : merge(
merge(local.default.build_definition[config], local.build_definition_values[build_definition][config]),
{
for subconfig in ["override"] :
subconfig => lookup(local.build_definition_values[build_definition][config], subconfig, {}) == {} ? null : merge(
merge(local.default.build_definition[config][subconfig], local.build_definition_values[build_definition][config][subconfig]),
{
for subsubconfig in ["branch_filter", "path_filter"] :
subsubconfig => merge(local.default.build_definition[config][subconfig][subsubconfig], lookup(local.build_definition_values[build_definition][config][subconfig], subsubconfig, {}))
}
)
}
)
},
{
for config in ["variable"] :
config => keys(local.build_definition_values[build_definition][config]) == keys(local.default.build_definition[config]) ? {} : {
for key in keys(local.build_definition_values[build_definition][config]) :
key => merge(local.default.build_definition[config], local.build_definition_values[build_definition][config][key])
}
}
)
}
}