-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path22_locals.tf
44 lines (33 loc) · 2.19 KB
/
22_locals.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
locals {
infrastructureSizeRegex = "^(.*?)\\.(\\d*)"
infrastructureSize = regex(local.infrastructureSizeRegex, "${var.infrastructureSize}.1")[0]
// if no multiplier is provided it defaults to 1 because of the string concat
resourceMultiplier = parseint(regex(local.infrastructureSizeRegex, "${var.infrastructureSize}.1")[1], 10)
// splits resource value from resource type
// used together with resourceMultiplier to adjust requests/limits
resourceMultiplierRegex = "^(0?\\.?\\d*)(.*)"
}
locals {
configVolumeMounts = { for k,v in var.applicationConfig.configVolumes: k => v if v.enableSubpathMount == false}
tmpConfigVolumeSubpathMounts = { for k,v in var.applicationConfig.configVolumes: k => merge(v, { key = k}) if v.enableSubpathMount == true }
configVolumeSubpathMounts = merge([ for k,v in local.tmpConfigVolumeSubpathMounts: {for f, z in merge(v.data, v.binaryData): "${k}-${f}" => { key = v.key, file = f, path = "${trimsuffix(v.path, "/")}/${f}"}} ]...)
secretVolumeMounts = { for k,v in var.applicationConfig.secretVolumes: k => v if v.enableSubpathMount == false}
tmpSecretVolumeSubpathMounts = { for k,v in var.applicationConfig.secretVolumes: k => merge(v, { key = k}) if v.enableSubpathMount == true }
secretVolumeSubpathMounts = merge([ for k,v in local.tmpSecretVolumeSubpathMounts: {for f, z in merge(v.data, v.binaryData): "${k}-${f}" => { key = v.key, file = f, path = "${trimsuffix(v.path, "/")}/${f}"}} ]...)
schedule = var.podResourceType == "cronjob" ? var.podResourceTypeConfig.schedule != null ? var.podResourceTypeConfig.schedule : "${random_integer.cronjobMinute.0.result} ${random_integer.cronjobHour.0.result} * * ${random_integer.cronjobDayOfWeek.0.result}" : ""
}
resource "random_integer" "cronjobMinute" {
count = var.podResourceType == "cronjob" && var.podResourceTypeConfig.schedule == null ? 1 : 0
min = 0
max = 59
}
resource "random_integer" "cronjobHour" {
count = var.podResourceType == "cronjob" && var.podResourceTypeConfig.schedule == null ? 1 : 0
min = 0
max = 23
}
resource "random_integer" "cronjobDayOfWeek" {
count = var.podResourceType == "cronjob" && var.podResourceTypeConfig.schedule == null ? 1 : 0
min = 0
max = 6
}