-
Notifications
You must be signed in to change notification settings - Fork 6
/
spectro-cluster-common-addons.tf
82 lines (73 loc) · 3.1 KB
/
spectro-cluster-common-addons.tf
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
locals {
cluster_addon_profiles_map = {
for v in var.clusters :
v.name => concat(try([v.profiles.system], []), concat(try(v.profiles.addons, []), try(v.profiles.addon_deployments, [])))
}
addon_pack_params_replaced = { for v in flatten([
for k, v in local.cluster_addon_profiles_map : [
for e in v : [
for p in try(e.packs, []) : {
name = format("%s$%s%%%s%%%s$%s", k, e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name)
value = join("\n", [
for line in split("\n", try(p.is_manifest_pack, false) ?
element([for x in local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name)].manifest : x.content if x.name == p.manifest_name], 0) :
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name)].values) :
format(
replace(line, "/'%(${join("|", keys(p.params))})%'/", "%v"),
[
for value in flatten(regexall("%(${join("|", keys(p.params))})%", line)) :
lookup(p.params, value)
]...
)
])
} if p.override_type == "params"
]
]]) : v.name => v.value
}
addon_pack_template_params_replaced = { for v in flatten([
for k, v in local.cluster_addon_profiles_map : [
for e in v : [
for p in try(e.packs, []) : {
name = format("%s-%s-%s", k, e.name, p.name)
value = join("\n", flatten([for l in p.params : [
join("\n", [
for line in split("\n", try(p.is_manifest_pack, false) ?
element([for x in local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name)].manifest : x.content if x.name == p.manifest_name], 0) :
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name)].values) :
format(
replace(line, "/%(${join("|", keys(l))})%/", "%s"),
[
for value in flatten(regexall("%(${join("|", keys(l))})%", line)) :
lookup(l, value)
]...
)
])
]]))
} if p.override_type == "template"]
]
]) : v.name => v.value
}
addon_pack_manifests = { for v in flatten([
for k, v in local.cluster_addon_profiles_map : [
for e in v : [
for p in try(e.packs, []) : {
name = format("%s$%s%%%s%%%s$%s", k, e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name)
value = [{
#identifier = format("%s-%s%%%s%%%s-%s-%s", k, e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name, p.manifest_name)
name = p.manifest_name
content = lookup(local.addon_pack_params_replaced, format("%s$%s%%%s%%%s$%s", k, e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name),
lookup(local.addon_pack_template_params_replaced, format("%s$%s%%%s%%%s$%s", k, e.name, try(e.version, "1.0.0"), try(e.context, "project"), p.name), "")
)
}]
} if try(p.is_manifest_pack, false)]
]
]) : v.name => v.value
}
}
output "debug_addon_pack_manifests" {
value = local.addon_pack_manifests
}
# not addon specific
output "debug_cluster_profile_pack_map" {
value = local.cluster-profile-pack-map
}