JavaScript Action

Registered by Renat Akhmerov

Rules:
use a variable to pass data in, by defaul we want the whole in_context
use $. global variable to refer to data (in_context)
use return to return the result in JavaScript
returned result goes straign to task result (like usual)
publish, like usual.

task_simple
   action: javascript in_context=[foo,bar] script="return 1+2"

task0:
    action: std.javascript
  input:
     in_context: $ // the $ in the script will be pointing to this
     script: |
        x = $.foo.bar // prev published var
        y = $.task_somewhere_before.x.y
        return {'x': x, 'y': y } # this becomes result
    publish:
        xxx: {$.task0.x.foo.bar}

task_1:
    action: foo.bar par={$.task0.y} # when we eventually can refer to tasks

JavaScript to evaluate :
   $=context // copy the in_context value here

   function f () {
      >> body of the script <<
   }

   f()

2. To automatically send in_context, use __env
__env = {
       '__action' {
             'javascript': {
                in_context: {$}
              },
              ...

3. Leverage default variables for action inputs.
Default variables shall be evaluated; if they contain YAQL, resolved
to actual values before passing to executors. Hm.. assume we get the signature meta data
availabe on the engine... Think about it.

When this is done, javascript action will look like:
    def __init__(self, in_context="{$}", script)

Blueprint information

Status:
Complete
Approver:
Renat Akhmerov
Priority:
High
Drafter:
Renat Akhmerov
Direction:
Approved
Assignee:
Nikolay Makhotkin
Definition:
Approved
Series goal:
Accepted for kilo
Implementation:
Implemented
Milestone target:
milestone icon 2015.1
Started by
Nikolay Makhotkin
Completed by
Renat Akhmerov

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/mistral-javascript-action,n,z

Addressed by: https://review.openstack.org/150757
    JavaScript action: part 1

Addressed by: https://review.openstack.org/151244
    JavaScript action: part 2

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.