Rick
Rick

Reputation: 602

How do you use/reference libraries in IBM Bluemix OpenWhisk?

As of today, in the IBM Bluemix docs for the IBM Bluemix OpenWhisk service I could not find any clues as to how to use libraries.

How am I missing the obvious that all apps invariably require a library and therefore why isn't that at least mentioned in the OpenWhisk docs?

If libraries are called something else or the concept doesn't apply in the usual way (such as maybe Libraries need to be converted into "OpenWhisk Packages"?), the OpenWhisk docs should SAY SOMETHING about the word/term/concept "libraries".

Upvotes: 1

Views: 175

Answers (2)

Rob Allen
Rob Allen

Reputation: 12778

To cover another language for anyone who finds this question…

For Swift, OpenWhisk comes with the Kitura-net, SwiftyJSON & swift-watson-sdk packages (Swift term for libraries) built in.

If you want to include any other packages then you have to either build your own Docker container for your action or concatenate all the Swift source files that are in the packages together with your action file to create a single .swift file for upload with wsk action update. I've used cat to do this:

cat lib/Redis/Redis*.swift actions/_common.swift actions/counts.swift > build/counts.swift

which creates a single build/counts.swift containing Kitura-Redis, some common code and my counts action.

Upvotes: 1

Ram Vennam
Ram Vennam

Reputation: 3546

You can use webpack to bundle all your dependencies and create the final .js file you'll use as your OpenWhisk action.

See this example: These are all the actions before webpack build: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/tree/dev/actions

Invoking webpack: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/blob/dev/package.json webpack --config webpack.config.js

Here is another more simpler example: https://github.com/IBM-Bluemix/openwhisk-webpack

Upvotes: 3

Related Questions