Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] multi-dimensional for_each #48

Open
Infinoid opened this issue Dec 19, 2021 · 0 comments
Open

[feature request] multi-dimensional for_each #48

Infinoid opened this issue Dec 19, 2021 · 0 comments

Comments

@Infinoid
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant