Skip to content

Commit

Permalink
Add support for named placeholders in custom task
Browse files Browse the repository at this point in the history
'custom' tasks can have named placeholders to be applied to the
'command'
Azure#374
  • Loading branch information
mohzah committed May 19, 2022
1 parent 0f20c7f commit 659fd59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion convoy/task_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ def generate_task(task, storage_settings):
args = module.generate()
for arg in args:
taskcopy = copy.copy(base_task_copy)
taskcopy['command'] = taskcopy['command'].format(*arg)
if isinstance(arg, collections.Mapping):
taskcopy['command'] = taskcopy['command'].format(**arg)
else:
taskcopy['command'] = taskcopy['command'].format(*arg)
yield taskcopy
elif 'file' in task_factory:
for file in _get_storage_entities(task_factory, storage_settings):
Expand Down
5 changes: 3 additions & 2 deletions docs/35-batch-shipyard-task-factory-merge-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ positional argument (i.e., `*args`), we are creating a range from `0` to that
argument value and `yield`ing the result as a iterable (tuple). Yielding
the result as an iterable is mandatory as the return value is unpacked and
applied to the `command`. This allows for multiple parameters to be generated
and applied for each generated task. An example corresponding configuration
may be similar to the following:
and applied for each generated task. The iterable can also be a dictionary to
allow named placeholders when applied to `command'. An example corresponding
configuration may be similar to the following:

```yaml
task_factory:
Expand Down

0 comments on commit 659fd59

Please sign in to comment.