Skip to content

Commit

Permalink
Merge pull request #6 from skyscrapers/fix/cron-syntax
Browse files Browse the repository at this point in the history
Fix: Cron syntax not correct for scaledobject
  • Loading branch information
simonrondelez authored Dec 13, 2024
2 parents 60631ef + 5b20c1d commit ebe8510
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
18 changes: 5 additions & 13 deletions scaledobject.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ resource "kubernetes_manifest" "scaledobject_cron" {
"minReplicaCount" = 0
"maxReplicaCount" = 1
"triggers" = [
{
"type" = "cron"
for trigger in lookup(each.value, "triggers", []) : {
"type" = "cron"
"metadata" = {
"timeZone" = lookup(each.value, "timeZone", "UTC")
"schedule" = lookup(each.value, "working_hours", "0 6-23 * * 1-5")
"desiredReplicas" = "1"
}
},
{
"type" = "cron"
"metadata" = {
"timeZone" = lookup(each.value, "timeZone", "UTC")
"schedule" = lookup(each.value, "non_working_hours", "0 0-5 * * 1-5, 0-23 * * 6, 0-23 * * 7")
"desiredReplicas" = "0"
"schedule" = trigger.cronSyntax
"timeZone" = trigger.timeZone
"desiredReplicas" = tostring(trigger.desiredReplicas)
}
}
]
Expand Down
8 changes: 5 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ variable "bitbucket_runners" {
}))
}))
cron_scaling_enabled = optional(bool, false)
timeZone = optional(string, "UTC")
working_hours = optional(string, "0 6-23 * * 1-5")
non_working_hours = optional(string, "0 0-5 * * 1-5,0-23 * * 6,0-23 * * 7")
triggers = optional(list(object({
cronSyntax = string
timeZone = string
desiredReplicas = number
})), [])
}))
description = "Map of Bitbucket runner definitions"
}
Expand Down

0 comments on commit ebe8510

Please sign in to comment.