yaml formatted data
Assuming a variable ARRAY like in https://taskfile.dev/blog/any-variables/#arrays , but YAML formatted. Is it possible, loop over a variable containing YAML formatted data (in this case a list) either inline or loaded from a .yaml file with templating functions?
example data:
Any Variables | Task
Task variables are no longer limited to strings!
4 Replies
@cloudneopren , I want to make sure I understand your question. The example in the docs shows:
Are you asking about whether you can format the array like this?
If so, yes. Both formats are valid YAML.
If that is not your question, could you expand on it?
Hi @pbitty, this goes into the right direction. My use case: In case there is a file
file.json
with a list of tools to be installed each with configurable package managers: [{"cosign":{"pkm":"arkade"}},{"flux":{"pkm":"go"}},{"kubectl":{"pkm":"arkade"}}]
Not sure, how to reference the key of the map and the "pkm" field:
I think your issue is that the top-level type in
file.json
is not a map but an array. If I use the following file.json
:
And the following Taskfile:
I get the output:
Would something like that work for your use-case?Thanks, looks good