-
Notifications
You must be signed in to change notification settings - Fork 8
Description
for_each is useful for enumerating a list of targets. I use it to loop over multiple Debian and Ubuntu releases, say ["buster", "bullseye", "bionic", "focal"]. So I have a distros/ folder with one yaml file in it per target distribution, each with the tag names and other details that are necessary for building for that distro.
I'd like to add target architectures to that, but it does not seem possible. I want to add a second loop over the target architecutres, say ["aarch64", "powerpc64", "x86_64"], which works the same way: an arches/ folder with one yaml file in it per target architecture, each with the details necessary for building for that architecture.
The desired result would be a nested pair of for-loops, one for distro, one for architecture. Like this pseudo-code:
for arch in ["aarch64", "powerpc64", "x86_64"]:
for distro in ["buster", "bullseye", "bionic", "focal"]:
arch_fn = "arches/" + arch + ".yaml"
distro_fn = "distros/" + distro + ".yaml"
output = merge(all_inputs, arch_fn, distro_fn)
out_fn = "outdir/" + distro + "_" + arch + ".yaml"
write(out_fn, output)This would produce the cartesian product of files in distros/ and files in arches/; with one merged output file for each pairing. This syntax is not limited to 2 dimensions, but my current use case is 2-dimensional.
One possible aviator.yml syntax might look like this:
spruce:
- base: resources.yaml
for_each:
- in: distros/
- in: arches/
merge:
[...]I can kinda get functionality similar to this now, by generating a third directory full of pre-merged pairings like "focal_aarch64.yaml", "bullseye_x86_64.yaml", etc, and using for_each to loop over those. But to accomplish this, I'm doing ugly shell loops in a Makefile... it would be nice if the tool could automate this.