You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/11/26 14:00:26 UTC

[GitHub] rabbah commented on issue #2927: bash kind action

rabbah commented on issue #2927: bash kind action
URL: https://github.com/apache/incubator-openwhisk/issues/2927#issuecomment-347010085
 
 
   @sungjunyoung thanks for sharing your changes - looks like the main change you made is to recursively project the JSON object's fields into env vars. Did you consider using [`jq`](https://stedolan.github.io/jq/tutorial/) instead?
   
   ```bash
   > cat exec 
   #!/bin/bash
   
   apk update && apk add jq 
   
   ARGS=$@
   A=`echo "$ARGS" | jq '."a"'`
   B=`echo "$ARGS" | jq '."b"'`
   C=`echo "$ARGS" | jq '."c"[0]'`
   RES=$(($B + $C))
   
   echo A is $A
   echo "{\"result\": $RES }"
   ```
   
   ```bash
   > wsk action create bash exec --native
   ok: created action bash
   
   > wsk action invoke bash -p a A -p b 123 -p c '[1,2,3]' -r
   {
       "result": 124
   }
   ```
   
   `jq` isn't installed in the base docker skeleton image yet but that'll be useful to add. It would avoid modifying the proxy as an alternative.
   
   (The other change I see in the proxy is the auto boxing of the last line into a JSON object for convenience.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services