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

Support for array/list/set parameter and foreach #45

Open
matfax opened this issue Aug 18, 2018 · 8 comments
Open

Support for array/list/set parameter and foreach #45

matfax opened this issue Aug 18, 2018 · 8 comments
Labels
enhancement New feature or request

Comments

@matfax
Copy link

matfax commented Aug 18, 2018

I would like to make another suggestion for a further feature. For me, it would come very handy if you added support for some kind of array, list or set parameter that can be parsed to a list of steps. Here is an example of how it may look:

commands:
  send:
    parameters:
      messages:
        description: "Messages to use"
        type: list #sorted
        items: # like Swagger
          type: string
        default: ["hey", "ho"]
    steps:
    - run: wait for connection
    - foreach:
        elements: << parameters.messages >>
        steps:
          - run: prepare next message
          - run: send << foreach.messages >> # use a different prefix group allowing nested foreachs without conflicts
    - foreach:
        elements: << parameters.messages >>
        id: msg
        steps:
          - run: prepare saving
          - run: save << foreach.msg >>

This is just an example, but imagine the same for build preparation where you pass a variable number of arguments per build, having a 1:n relation. I could use that for docker tag << foreach.tag >>.

@dnephin
Copy link

dnephin commented Aug 20, 2018

It seems to me like a string type would be more appropriate for your example. The values are being used as part of a shell command, which is a string. Using a list introduces new problems, like how should the list be joined to create a string (which is what is actually needed). We could assume it will always be joined with a single space, but that may not always be a safe assumption.

Edit: reading the last line I see that the desired behaviour is not what I first expected. It is to expand a single step into multiple steps.

@matfax
Copy link
Author

matfax commented Aug 20, 2018

@dnephin You are right, foreach would be more appropriate.

@matfax matfax changed the title Support for array/list/set parameter and maps Support for array/list/set parameter and foreach Aug 20, 2018
@ndintenfass
Copy link
Contributor

This is something we're exploring, but we're hesitant to put too much control flow logic at the meta-layer. We aren't trying to build a programming language in YAML, but we do want to find ways to let you do common things in a DRY way.

@ndintenfass ndintenfass added the enhancement New feature or request label Aug 24, 2018
@bunchc
Copy link

bunchc commented May 31, 2019

Hello,
Is there a way or practice or method by which this can achieved in the current product?
Thanks!

@davidbarkhuizen
Copy link

davidbarkhuizen commented Dec 20, 2022

+100. Please implement as soon as possible.

@doron2402
Copy link

Any update on that?

@eytan-sankin
Copy link

Would come in handy indeed.

@matfax
Copy link
Author

matfax commented Nov 17, 2023

I'm quite disappointed that this is still unresolved, after five years.

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

No branches or pull requests

7 participants