In the previous “Hello world” example, the wskdeploy
utility used the file extension of the function “hello.js” to select the most current NodeJS runtime.
In most cases, allowing the utility to select the runtime works well using this implicit method. However, perhaps your code is dependent on a specific version of a language runtime and you want to explicitly set it?
This example shows how to:
packages: hello_world_package: version: 1.0 license: Apache-2.0 actions: hello_world_runtime: function: src/hello.js runtime: nodejs@10
$ wskdeploy -m docs/examples/manifest_hello_world_runtime.yaml
$ wsk action invoke hello_world_package/hello_world_runtime --blocking
The invocation should return an ‘ok’ with a response that includes this result:
"result": { "greeting": "Hello, undefined from undefined" },
In the above example,
runtime
’ key was a valid name and version supported by OpenWhiskIf the language runtime you requested is not compatible with the function's language, then you will receive an error response when invoking the Action. For example, the following manifest indicates a JavaScript (.js
) function, but the runtime selected as “python
”:
package: name: hello_world_package ... actions: hello_world_runtime: function: src/hello.js runtime: python
The result would a “failure” with a failed response:
"response": { "result": { "error": "The action failed to generate or locate a binary. See logs for details." }, "status": "action developer error", "success": false
The source code for the manifest and JavaScript files can be found here:
For convenience, the Packages and Actions grammar can be found here:
curl -k <OpenWhisk API_HOST>
For example, you can test this against the IBM Cloud Functions platform:
curl -k https://openwhisk.ng.bluemix.net