Hey guys,
I'm working on a workflow project that uses YAML files to define workflows.
We are starting to design a new version with the goal of improving the syntax to make it easier for developers to write workflows.
One of the main new feature is to include YAML file using the following syntax: ${ file('workflows/foo.yml') }
.
I would like to know which of the following YAML style do you prefer.
Map style
# main.yml
name: my first app
workflows:
foo-workflow:
steps:
- ...
bar-workflow: ${ file('workflows/bar.yml') }
# workflows/bar.yml
steps:
- ...
-
workflows
is a map - workflow's name defined only in the main file
Array style
# main.yml
name: my first app
workflows:
- name: foo workflow
steps:
- ...
- ${ file('workflows/bar.yml')}
# workflows/bar.yml
name: bar workflow
steps:
- ...
-
workflows
is an array - workflow's name defined is the workflow's file
Top comments (4)
Hmmm -- YAML preserves the ordering of maps, so you could get away with the first, but it seems to me that anything where you're literally calling things "first," "second," "third," etc. implies a list. Especially if you might later end up having to parse it into JSON or into programming languages where dicts aren't ordered.
But that's mostly if you think your numbers will stretch beyond, say, 10.
If you know it's more like "primary" and "backup," you could probably get away with either. What do your teammates like?
Also, you might want to add a "discuss" tag to this.
Thanks for your comment!
The workflows are not actually ordered. My bad for using “first” and “second”, it brings confusion to the discussion. I will edit now.
They prefer the map version but I want to make sure it’s the best ;)
Tag added. Thanks for the suggestion.
Should two workflows be allowed to have the same name? If not, map style.
Good point!
Workflows cannot have the same name.
Thanks for this simple yet efficient argument.