tree: 823da336c5a37648bb7acdaa99b85aa287506848 [path history] [tgz]
  1. README.md
  2. build.gradle
  3. src/
tools/dev/README.md

Utility Scripts

This module is a collection of few utility scripts for OpenWhisk development. The scripts can be invoked as gradle tasks. Depending on your current directory the gradle command would change

With current directory set to OpenWhisk home

./gradlew :tools:dev:<taskName>

With this module being base directory

../../gradlew <taskName>

couchdbViews

Extracts and dump the design docs js in readable format. It reads all the design docs from <OPENWHISH_HOME>/ansibles/files and dumps them in build/views directory

Sample output

$./gradlew :tools:dev:couchdbViews
Processing whisks_design_document_for_entities_db_v2.1.0.json
        - whisks.v2.1.0-rules.js
        - whisks.v2.1.0-packages-public.js
        - whisks.v2.1.0-packages.js
        - whisks.v2.1.0-actions.js
        - whisks.v2.1.0-triggers.js
Processing activations_design_document_for_activations_db.json
        - activations-byDate.js
Processing auth_design_document_for_subjects_db_v2.0.0.json
        - subjects.v2.0.0-identities.js
Processing filter_design_document.json
Processing whisks_design_document_for_activations_db_v2.1.0.json
        - whisks.v2.1.0-activations.js
Skipping runtimes.json
Processing logCleanup_design_document_for_activations_db.json
        - logCleanup-byDateWithLogs.js
Processing whisks_design_document_for_all_entities_db_v2.1.0.json
        - all-whisks.v2.1.0-all.js
Processing whisks_design_document_for_activations_db_filters_v2.1.0.json
        - whisks-filters.v2.1.0-activations.js
Generated view json files in /path/too/tools/build/views

IntelliJ Run Config Generator

This script enables creation of Intellij Launch Configuration in /.idea/runConfigurations with name controller0 and invoker0. For this to work your Intellij project should be directory based. If your project is file based (uses ipr files) then you can convert it to directory based via File -> Save as Directory-Based Format. These run configurations can then be invoked from Run -> Edit Configurations -> Application

Usage

First setup OpenWhisk so that Controller and Invoker containers are up and running. Then run the script:

./gradlew :tools:dev:intellij

It would inspect the running docker containers and then generate the launch configs with name ‘controller0’ and ‘invoker0’.

Now the docker container(s) (controller and/or invoker) can be stopped and they can be launched instead from within the IDE.

Key points to note:

  1. Controller uses port 10001 and Invoker uses port 12001.
  2. Action activation logs are disabled.
  3. SSL is disabled for Controller and Invoker.
  4. Make sure you have the loopback interface configured:
    sudo ifconfig lo0 alias 172.17.0.1/24
    
  5. ~/.wskprops must be updated with APIHOST=http://localhost:10001 so that the wsk CLI communicates directly with the controller.
  6. On a MAC
    • With Docker For Mac the invoker is configured to use a Container Factory that exposes ports for actions on the host, as otherwise the invoker can't make HTTP requests to the actions. You can read more at docker/for-mac#171.

    • When using docker-compose locally you have to update /etc/hosts with the line bellow:

      127.0.0.1       kafka zookeeper kafka.docker zookeeper.docker db.docker controller whisk.controller
      

Configuration

The script allows some local customization of the launch configuration. This can be done by creating a config file intellij-run-config.groovy in project root directory. Below is an example of /intellij-run-config.groovy file to customize the logging and db port used for CouchDB.

//Configures the settings for controller application
controller {
    //Base directory used for controller process
    workingDir = "/path/to/controller"
    //System properties to be set
    props = [
            'logback.configurationFile':'/path/to/custom/logback.xml'
    ]
    //Environment variables to be set
    env = [
            'DB_PORT' : '5989',
            'CONFIG_whisk_controller_protocol' : 'http'
    ]
}

invoker {
    workingDir = "/path/to/invoker"
    props = [
            'logback.configurationFile':'/path/to/custom/logback.xml'
    ]
    env = [
            'DB_PORT' : '5989'
    ]
}

The config allows following properties:

  • workingDir - Base directory used for controller or invoker process.
  • props - Map of system properties which should be passed to the application.
  • env - Map of environment variables which should be set for application process.

Github Repository Lister

Lists all Apache OpenWhisk related repositories by using Github Search API with pagination. Its preferable that prior to using this you specify a Github Access Token as otherwise requests will quickly become rate limited. The token can be specified by setting environment variable GITHUB_ACCESS_TOKEN

$ ./gradlew :tools:dev:listRepos
Found 44 repositories
openwhisk
openwhisk-GitHubSlackBot
openwhisk-apigateway
openwhisk-catalog
...
Stored the list in /openwhisk_home/build/repos/repos.txt
Stored the JSON details in /openwhisk_home/build/repos/repos.json

It generates 2 files

  • repos.txt - List repository names one per line.
  • repos.json - Stores an array of repository details JSON containing various repository related details.

OpenWhisk Module Status Generator

It renders a markdown file which lists the status of various OpenWhisk modules by using the output generated by listRepos task. The rendered markdown file is stored in docs/dev/modules.md. This rendered file should be later checked in.

$ ./gradlew :tools:dev:renderModuleDetails

  > Task :tools:dev:renderModuleDetails
  Generated modules details at /openwhisk_home/docs/dev/modules.md