-
Hi, Example target "app" {
name = "app-${tgt}"
matrix = {
tgt = ["foo", "bar"]
}
target = tgt
} running Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
How about using a ternary/variable to check for an override? Something like: variable "MATRIX_OVERRIDE" { default="" }
function "list" {
params = []
variadic_params = items
result = items
}
target "app" {
name = "app-${tgt}"
matrix = {
tgt = notequal("",MATRIX_OVERRIDE) ? list(MATRIX_OVERRIDE) : list("foo", "bar")
}
target = tgt
} |
Beta Was this translation helpful? Give feedback.
-
My current workaround is to use the string of a JSON array as environment variable that is then It works but it's kinda ugly: variable "MY_CHOICES" {
default = "[\"one\",\"two\",\"three\"]"
}
function "mychoices" {
params = [choices]
result = jsondecode(choices)
}
target "mytarget" {
matrix = {
choice = mychoices(MY_CHOICES)
}
name = "mytarget-${choice}"
}
I didn't find a way to directly define the tuple content as env var that the HCL parser could resolve as tuple to allow overriding it: variable "mychoices" {
default = ["one", "two", "three"]
}
target "mytarget" {
matrix = {
choice = mychoices
}
name = "mytarget-${choice}"
} Current error: $ mychoices='["four","five"]' docker buildx bake
1 | >>> variable "mychoices" {
2 | default = ["one", "two", "three"]
3 | }
--------------------
ERROR: bake.hcl: Invalid value; unsupported type tuple for variable mychoices I'd love to be able to set |
Beta Was this translation helpful? Give feedback.
How about using a ternary/variable to check for an override? Something like: