Allow list-type parameters in Orbs
D
Dave Henderson
It'd be useful to allow handling lists of values for a parameter, without having to resort to workarounds like parsing comma-separated lists in
string
types.I think it would be useful to be able to specify something like:
steps:
- myorb/foo:
bar:
- baz
- qux
And have the
myorb/foo
command called with a bar
parameter equal to [ "baz", "qux" ]
.CCI-I-701
Minjun Seong
Hi folks! I'm a product manager at CircleCI. Would it be possible for you to:
- Elaborate on your specific use case that led you to request for a list type parameter?
- Provide an example on how are you currently working around this limitation?
This would greatly help me better understand the pain point, thank you!
k
kevin.kortum@trustedshops.com
Minjun Seong Sure :)
My most used scenario is for orbs. Consider the php orb at https://circleci.com/developer/orbs/orb/circleci/php
To install extensions, you will have to write the following YAML
- php/install_php:
version: "8.2"
extensions: "php8.2-fpm,php8.2-phpdbg,php8.2-zip,php8.2-xml,php8.2-dom,php8.2-mbstring,php8.2-sockets,php8.2-gd,php8.2-soap,php8.2-curl,php8.2-intl,php8.2-mysql"
As you can see the extensions information gets quite convoluted. So having a list type would be nice in terms of readability. I'd also imagine it would be easier to iterate over so that you could potentially drop the "php8.2-" prefix in the example above.
I wrote another private orb for automating dependency installations. It uses an allow list to decided which dependencies can be updated. To make it work, i have to deal with a custom string and pattern matching instead of using a nice list, which would allow me to check if an item is part of it.
Consider
parameters:
capabilities:
description: "Comma-separated list of additional tools to set up. Use 'all' to install all known tools (default)."
default: "all"
type: string
steps:
- checkout
- when:
condition:
matches:
value: << parameters.capabilities >>
pattern: "(all|tool-a)"
steps:
- install_tool-a
- when:
condition:
matches:
value: << parameters.capabilities >>
pattern: "(all|tool-b)"
steps:
- install_tool-b
- when:
condition:
matches:
value: << parameters.capabilities >>
pattern: "(all|tool-c)"
steps:
- install_tool-c
The list version would look probably like this
# ...
- when:
condition:
or: [ "tool-a" in << parameters.capabilities >>, "all" in << parameters.capabilities >>]
steps:
- install_tool-a
The actual condition would depend on the implementation, but i think someone could come up with a clever way to do it.
k
kevin.kortum@trustedshops.com
Push for an update. Why does this ideas page even exist when this is not even recognized?
T
Tal Marcovich
Is there any update on this? This is a feature request from 2018...
N
Nelson, Pete
My use case is i want the ability to bake my caching logic into my install dependencies command. But I have no way of passing the
paths
parameter to my command until you add list type. This is bothersome I have no way to do thisJames Nail
Nelson, Pete this is exactly my use case as well!
R
Rob Duncan
Any updates on this? Not being able to create a basic yaml structure list like this feels so inadequate in 2023.
Jeff Valore
I ran into this limitation trying to set up standard workflows for installing dependencies then caching them (i.e. run
yarn install
then save_cache the downloaded files) but since you can't take in a List, you can't pass customizable paths through your own command to save_cache
.We are approaching 5 years and this unfortunately still doesn't exist. CircleCI could have been so good, but necessary functionality like this is never added (I've given up on so many CI plans due to the CircleCI limitations). Passing Lists must already exist in some form because
save_cache
can take a "List".Jonas steinberg
Still needed. Folks iterating in templates is an old thing, e.g. xml, erb, ego, helm. I think we just need to get over it and do it here because not having a parameter of type list is fairly comical at this point and probably something that all other CIs do.
D
Diógenes Fernandes Hermínio
What is the current workaround for that?
g
gleb.stsenov@gmail.com
it also needs some helpers around it - at least for-loop and concatenation.
Wish CircleCI could opensource this part..
Steve Lewis
Similar to many below, I just ran into this in trying to template our usage of persist_to_workspace paths for a private orb.
FWIW - I believe this wouldn't need any looping construct to be valuable in many contexts.
Load More
→