List parameter type?

orbs

#1

I’m new to orbs, and started playing around with creating an orb for one of my tools.

One of the parameters I want to take as input can be specified multiple times, but there doesn’t seem to be an appropriate parameter type for this, according to https://circleci.com/docs/2.0/reusing-config/#parameter-types.

In the meantime, I can use a comma-separated string, but this is a bit non-obvious and will be slightly more difficult to deal with.

Is a list parameter type planned? Or is there some undocumented support already?


#2

We don’t yet have a generic list or collection type. One issue is that we have been hesitant to put looping constructs directly in our yaml for fear of creating a yaml-based programming language. That said, it’s clear that some way to pass multiple values would be useful, so it’s something we have on our list of improvements. Curious: how would you envision the syntax looking when you use a list? We could potentially pass it through serialized for use in shell commands, but that is a bit messier than we’d like.


#3

Thanks for the quick response, @ndintenfass

I’m used to dealing with the Go text/template package, in fact, the tool I’m trying to Orb-ify is https://github.com/hairyhenderson/gomplate, which is a template renderer that uses the text/template syntax.

So I’d imagine a syntax like this:

commands:
  foo:
    parameters:
      alist:
        type: list
    steps:
      - run: |
          << range parameters.alist >>echo "param is << . >>";<< end >>
jobs:
  - foo_job:
      - myorb/foo:
          alist:
            - first
            - second

This would output:

param is first
param is second

This is just off the top of my head, and probably isn’t as intuitive to folks who aren’t familiar with the text/template syntax!

Thanks,
-Dave


#4

I only mention this because of the specific example you used here @hairyhenderson, because I know this isn’t quite what you’re looking for in a broader sense, but you can use the steps parameter type to allow folks to pass a list/collection—as long as it’s a list of steps. Which would get you to your example, although it’s not quite as DRY as what you’ve outlined here.


#5

Thanks @rose - that looks like an interesting hack - I didn’t realize steps could be used that way…

But you’re right, it’s not quite what I’m looking for… :wink:

I’ll play around with it and see if it’s enough for now.