OpenWhisk is a cloud-first distributed event-based programming service. It provides a programming model to upload event handlers to a cloud service, and register the handlers to respond to various events. Learn more at the main repository openwhisk
This repository contains an interactive tutorials for the OpenWhisk CLI.
The Whisk tutorial is an interactive learning environment to get familiar with the whisk command line.
This project uses a simplified Django structure, builds on Django 1.6 and uses Python 2.7.
- Clone whisk-tutorial repository to your local machine
- Navigate to the whisk-tutorial folder
To run the application locally, execute the following commands from the whisk-tutorial directory:
pip install -r requirements.txt
python manage.py runserver localhost:8080
If you don't want bother run locally, you can run the tutorial in Docker with following comand:
docker build -t openwhisk-tutorial .
This command will help build the tutorial docker image.
sudo docker run --name whisk-tutorial -p 8081:8000 -d openwhisk-tutorial
THis command will start a container running the tutorial app with name whisk-tutorial, and map
port 8081 from host to port 8000 in the container.
Now, open your host web browser, and nagivate to http://localhost:8081, you should be able to practice with the tutorial now.
There are two options to deploy to bluemix - manually and through the "deploy" button.
- Change the name field in the manifest.yml to a preferred name
- Execute
cf push
from the whisk-tutorial directory
cf delete learnwhisk
NOTE: You will need to register for a Bluemix account.
install coffee-script: npm install -g coffee-script
install django-markdown-deux: pip install django-markdown-deux
- Locate home.md in the templates directory(i.e. whisk-tutorial/whisk_tutorial/tutorial/templates/home.md)
- Add a new div tag to the tutorial links div
All the steps are stored in arrays. The basic tutorial is stored in 'q' while the advanced tutorial is stored in 'adv_q' both of which can be found in steps.coffee. If you follow the pattern in the steps.coffee file it should be fairly trivial to figure out how to modify a question. When steps.cofee is modified you will need to compile the .coffee files to javascript file. For this you will need to have coffee-script installed on your computer. see "Install dev tools" section above.
- Open the steps.coffee file that is located in whisk_tutorial/static/js directory.
- Locate the corresponding queue to which you'd like add a step to. For example, trigger_q holds all the step items for the trigger tutorial.
- Push a new item to the corresponding q. You can reuse the structure from previous steps.
Example: trigger_q.push({...})
compilation command: coffee -c steps.coffee
this will generate the steps.js file.
The interpreter is written in terminal.coffee, in the 'wsk' function. The itepreter logic is a set of if else statements. The logic flow is pretty straight forward. To generate the js file, run the following:
- Open the terminal.coffee file that is located in the whisk_tutorial/static/js directory.
- Adding a new command to the interpreter:
- Locate "WSK Interpreter" comment block
- Add a new if clause to the wsk if-else code block and echo to the corresponding variable holding the content for the output
- Adding content for the output of a command:
a. Locate "WSK Content" comment block.
b. Create a new variable holding the output content for the command to be added. - Compile the terminal.coffee file:
coffee -c terminal.coffee
Styling can be found in the tutorial-style.css file.
The codebase for this project was cloned from the docker-tutorial(https://github.com/docker/docker-tutorial/commits/master).
Copyright 2015-2016 IBM Corporation
Licensed under the Apache License, Version 2.0 (the "License").
Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license.
Report bugs, ask questions and request features here on GitHub.
We welcome contributions, but request you follow these guidelines
Happy coding!