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 2018/02/06 11:08:31 UTC

[GitHub] rabbah commented on a change in pull request #3244: Move parameter docs to separate page, add package params docs

rabbah commented on a change in pull request #3244: Move parameter docs to separate page, add package params docs
URL: https://github.com/apache/incubator-openwhisk/pull/3244#discussion_r166258588
 
 

 ##########
 File path: docs/parameters.md
 ##########
 @@ -0,0 +1,181 @@
+# Working with parameters
+
+It's possible to supply data to actions and these can be provided in a few different ways.  This page outlines how to configure parameters when deploying packages and actions, and how to supply parameters to actions when invoking the action.
+
+### Passing parameters to an action at invoke time
+
+Parameters can be passed to the action when it is invoked.  These examples use JavaScript but all the other languages work the same way.
+
+1. Use parameters in the action. For example, update the 'hello.js' file with the following content:
+
+  ```javascript
+  function main(params) {
+      return {payload:  'Hello, ' + params.name + ' from ' + params.place};
+  }
+  ```
+
+  The input parameters are passed as a JSON object parameter to the `main` function. Notice how the `name` and `place` parameters are retrieved from the `params` object in this example.
+
+2. Update the action so it is ready to use:
+
+  ```
+  wsk action update hello hello.js
+  ```
+
+3.  Parameters can be provided explicitly on the command-line, or by supplying a file containing the desired parameters
+
+  To pass parameters directly through the command-line, supply a key/value pair to the `--param` flag:
+  ```
+  wsk action invoke --result hello --param name Dorothy --param place Kansas
 
 Review comment:
   Show result here?

----------------------------------------------------------------
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