Ability to access Pack Config from orquesta workflow
SUMMARY
Currently if a user wants to access pack config data from an Orquesta workflow, the user must add an additional parameter to the action definition, set it to a default of {{ config_context.xxx }} and pipe it into the workflow.
---
name: "send_sms"
runner_type: "python-script"
description: "This sends an SMS using twilio."
enabled: true
entry_point: "send_sms.py"
parameters:
from_number:
type: "string"
description: "Your twilio 'from' number in E.164 format. Example +14151234567."
required: false
position: 0
default: "{{config_context.from_number}}"
It would be great if the pack's config was available in the workflow definition itself. This would allow users to do interesting this like accessing config keys based on output of actions.
I think it makes sense that the "config" in this case would be the config for the pack that the workflow resides in.
ISSUE TYPE
- Feature Idea
MOCK WORKFLOW
version: 1.0
description: A basic workflow that runs an arbitrary linux command.
input:
- cmd
- timeout
tasks:
task1:
action: core.local cmd=<% ctx(cmd) %> timeout=<% ctx(timeout) %>
next:
- when: <% succeeded() %>
publish:
- stdout: <% result().stdout %>
- stderr: <% result().stderr %>
task2:
# accessing the pack's config here
action: core.local cmd="ls <% config(ctx(stdout)) %>"
next:
- when: <% succeeded() %>
publish:
- data: <% result().stdout %>
output:
- stdout: <% ctx(data) %>
every time i start working with stackstorm and orquesta its like its missing all the basic features :-( like this one, should be in there before release it...
hope this feature in roadmap
For future reference (let's face it, mine when I run into this problem again), this can be worked around by creating an action in your pack like load_config which you use in your workflow:
load_config.py
from st2common.runners.base_action import Action
class LoadConfigAction(Action):
def run(self):
return self.config
load_config.yaml
---
name: load_config
runner_type: python-script
description: Set the pack config in the context
enabled: true
entry_point: load_config.py
parameters: {}
workflows/your_workflow.yaml
version: 1.0
tasks:
load_config:
action: micro.load_config
next:
- do:
- send_email
send_email:
action: micro.send_email
input:
template_name: team_invitation
to_email: <% ctx('invitee_email') %>
data:
invitation_url: "{{ task('load_config').result.result.one_of_your_config_keys }}/?itoken={{ ctx().invitation_id }}"
input:
- invitee_email
- invitation_id