From a1a3fe4b2bd2c4e1147d173ca79613ce4f88b908 Mon Sep 17 00:00:00 2001 From: Arjun Guha Date: Sun, 7 Jan 2018 21:40:02 +0530 Subject: [PATCH] Moved demo to IBM Cloud Functions (#5) --- .../Dockerfile | 11 + .../rehearsal-centos-6-package-list/README.md | 3 + .../action/.gitignore | 1 + .../action/js/index.js | 59 +++ .../action/package.json | 10 + .../action/yarn.lock | 293 +++++++++++ .../rehearsal-centos-6-package-list/update.sh | 8 + .../rehearsal-package-server/.gitignore | 3 + .../rehearsal-package-server/README.md | 8 + .../rehearsal-package-server/bin/update.sh | 6 + .../rehearsal-package-server/bin/zip.sh | 4 + .../rehearsal-package-server/package.json | 20 + .../rehearsal-package-server/ts/index.ts | 49 ++ .../rehearsal-package-server/tsconfig.json | 17 + .../rehearsal-package-server/yarn.lock | 479 ++++++++++++++++++ .../Dockerfile | 11 + .../README.md | 3 + .../action/.gitignore | 1 + .../action/js/index.js | 61 +++ .../action/package.json | 10 + .../action/yarn.lock | 293 +++++++++++ .../update.sh | 8 + cloud-functions/rehearsal/Dockerfile | 34 ++ cloud-functions/rehearsal/README.md | 4 + cloud-functions/rehearsal/action/.gitignore | 2 + cloud-functions/rehearsal/action/js/index.js | 50 ++ cloud-functions/rehearsal/action/package.json | 11 + .../rehearsal/action/rehearsal.conf | 12 + cloud-functions/rehearsal/action/yarn.lock | 303 +++++++++++ cloud-functions/rehearsal/update.sh | 8 + src/main/scala/ResourceModel.scala | 2 +- 31 files changed, 1783 insertions(+), 1 deletion(-) create mode 100644 cloud-functions/rehearsal-centos-6-package-list/Dockerfile create mode 100644 cloud-functions/rehearsal-centos-6-package-list/README.md create mode 100644 cloud-functions/rehearsal-centos-6-package-list/action/.gitignore create mode 100644 cloud-functions/rehearsal-centos-6-package-list/action/js/index.js create mode 100644 cloud-functions/rehearsal-centos-6-package-list/action/package.json create mode 100644 cloud-functions/rehearsal-centos-6-package-list/action/yarn.lock create mode 100755 cloud-functions/rehearsal-centos-6-package-list/update.sh create mode 100644 cloud-functions/rehearsal-package-server/.gitignore create mode 100644 cloud-functions/rehearsal-package-server/README.md create mode 100755 cloud-functions/rehearsal-package-server/bin/update.sh create mode 100755 cloud-functions/rehearsal-package-server/bin/zip.sh create mode 100644 cloud-functions/rehearsal-package-server/package.json create mode 100644 cloud-functions/rehearsal-package-server/ts/index.ts create mode 100644 cloud-functions/rehearsal-package-server/tsconfig.json create mode 100644 cloud-functions/rehearsal-package-server/yarn.lock create mode 100644 cloud-functions/rehearsal-ubuntu-trusty-package-list/Dockerfile create mode 100644 cloud-functions/rehearsal-ubuntu-trusty-package-list/README.md create mode 100644 cloud-functions/rehearsal-ubuntu-trusty-package-list/action/.gitignore create mode 100644 cloud-functions/rehearsal-ubuntu-trusty-package-list/action/js/index.js create mode 100644 cloud-functions/rehearsal-ubuntu-trusty-package-list/action/package.json create mode 100644 cloud-functions/rehearsal-ubuntu-trusty-package-list/action/yarn.lock create mode 100755 cloud-functions/rehearsal-ubuntu-trusty-package-list/update.sh create mode 100644 cloud-functions/rehearsal/Dockerfile create mode 100644 cloud-functions/rehearsal/README.md create mode 100644 cloud-functions/rehearsal/action/.gitignore create mode 100644 cloud-functions/rehearsal/action/js/index.js create mode 100644 cloud-functions/rehearsal/action/package.json create mode 100644 cloud-functions/rehearsal/action/rehearsal.conf create mode 100644 cloud-functions/rehearsal/action/yarn.lock create mode 100755 cloud-functions/rehearsal/update.sh diff --git a/cloud-functions/rehearsal-centos-6-package-list/Dockerfile b/cloud-functions/rehearsal-centos-6-package-list/Dockerfile new file mode 100644 index 0000000..3a87915 --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/Dockerfile @@ -0,0 +1,11 @@ +FROM centos:6 +MAINTAINER Arjun Guha + +RUN yum -y install yum-utils wget +RUN wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm +RUN rpm -ivh epel-release-6-8.noarch.rpm +RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - +RUN yum -y install nodejs +COPY action /action + +ENTRYPOINT ["/usr/bin/node", "/action/js/index.js"] \ No newline at end of file diff --git a/cloud-functions/rehearsal-centos-6-package-list/README.md b/cloud-functions/rehearsal-centos-6-package-list/README.md new file mode 100644 index 0000000..112d4ad --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/README.md @@ -0,0 +1,3 @@ +1. Install Node packages: `cd action && yarn install` +2. Create the action: `bx wsk action create rehearsal-centos-6-package-list --docker=arjunguha/rehearsal-centos-6-package-list` +3. To update the action: `./update.sh` \ No newline at end of file diff --git a/cloud-functions/rehearsal-centos-6-package-list/action/.gitignore b/cloud-functions/rehearsal-centos-6-package-list/action/.gitignore new file mode 100644 index 0000000..07e6e47 --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/action/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/cloud-functions/rehearsal-centos-6-package-list/action/js/index.js b/cloud-functions/rehearsal-centos-6-package-list/action/js/index.js new file mode 100644 index 0000000..8865f27 --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/action/js/index.js @@ -0,0 +1,59 @@ +// This is based on: +// +// https://github.com/apache/incubator-openwhisk-runtime-docker/blob/master/core/actionProxy/actionproxy.py +var express = require('express'); +var bodyParser = require('body-parser'); +var cp = require('child_process'); + +var app = express(); +var jsonParser = bodyParser.json() + +var LOG_SENTINEL = 'XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX\n'; + +function complete() { + process.stdout.write(LOG_SENTINEL); + process.stderr.write(LOG_SENTINEL); +} + +// This handler receives executable source code if an action is a ZIP file +// based on this image. But, we are never going to do that. +app.post('/init', function(req, resp) { + resp.status(200).send(); +}); + +app.post('/run', jsonParser, function(req, resp) { + var packageName = req.body.value.package; + if (typeof packageName !== 'string') { + resp.status(404).send(JSON.stringify({ + error: 'expected "package" parameter' + })); + complete(); + return; + } + + var cmd = `repoquery -l ${packageName}`; + cp.exec(cmd, + { encoding: 'utf8' }, + function(err, stdout, stderr) { + if (err !== null) { + resp.status(404).send(JSON.stringify({ + error: { + message: `error from ${cmd}`, + stdout: stdout, + stderr: stderr + } + })); + complete(); + return; + } + + var files = stdout.slice(0, stdout.length - 1) // drop trailing newline + .split('\n'); // one file per line + resp.status(200).send(JSON.stringify({ + files: files + })); + complete(); + }); +}); + +app.listen(8080); \ No newline at end of file diff --git a/cloud-functions/rehearsal-centos-6-package-list/action/package.json b/cloud-functions/rehearsal-centos-6-package-list/action/package.json new file mode 100644 index 0000000..d3a3cfd --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/action/package.json @@ -0,0 +1,10 @@ +{ + "name": "rehearsal-ubuntu-trusty-package-list", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "body-parser": "^1.18.2", + "express": "^4.16.2" + } +} diff --git a/cloud-functions/rehearsal-centos-6-package-list/action/yarn.lock b/cloud-functions/rehearsal-centos-6-package-list/action/yarn.lock new file mode 100644 index 0000000..063a79e --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/action/yarn.lock @@ -0,0 +1,293 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +accepts@~1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.4.tgz#86246758c7dd6d21a6474ff084a4740ec05eb21f" + dependencies: + mime-types "~2.1.16" + negotiator "0.6.1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + +body-parser@1.18.2, body-parser@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.1" + http-errors "~1.6.2" + iconv-lite "0.4.19" + on-finished "~2.3.0" + qs "6.5.1" + raw-body "2.3.2" + type-is "~1.6.15" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + +content-disposition@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +depd@1.1.1, depd@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +encodeurl@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + +express@^4.16.2: + version "4.16.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" + dependencies: + accepts "~1.3.4" + array-flatten "1.1.1" + body-parser "1.18.2" + content-disposition "0.5.2" + content-type "~1.0.4" + cookie "0.3.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.1" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.1.0" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.2" + path-to-regexp "0.1.7" + proxy-addr "~2.0.2" + qs "6.5.1" + range-parser "~1.2.0" + safe-buffer "5.1.1" + send "0.16.1" + serve-static "1.13.1" + setprototypeof "1.1.0" + statuses "~1.3.1" + type-is "~1.6.15" + utils-merge "1.0.1" + vary "~1.1.2" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +forwarded@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + +http-errors@1.6.2, http-errors@~1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + dependencies: + depd "1.1.1" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +iconv-lite@0.4.19: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ipaddr.js@1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + +mime-db@~1.30.0: + version "1.30.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" + +mime-types@~2.1.15, mime-types@~2.1.16: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" + dependencies: + mime-db "~1.30.0" + +mime@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + +proxy-addr@~2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec" + dependencies: + forwarded "~0.1.2" + ipaddr.js "1.5.2" + +qs@6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + +raw-body@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + dependencies: + bytes "3.0.0" + http-errors "1.6.2" + iconv-lite "0.4.19" + unpipe "1.0.0" + +safe-buffer@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +send@0.16.1: + version "0.16.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" + dependencies: + debug "2.6.9" + depd "~1.1.1" + destroy "~1.0.4" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "~1.6.2" + mime "1.4.1" + ms "2.0.0" + on-finished "~2.3.0" + range-parser "~1.2.0" + statuses "~1.3.1" + +serve-static@1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719" + dependencies: + encodeurl "~1.0.1" + escape-html "~1.0.3" + parseurl "~1.3.2" + send "0.16.1" + +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + +"statuses@>= 1.3.1 < 2": + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + +statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +type-is@~1.6.15: + version "1.6.15" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.15" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" diff --git a/cloud-functions/rehearsal-centos-6-package-list/update.sh b/cloud-functions/rehearsal-centos-6-package-list/update.sh new file mode 100755 index 0000000..4db4670 --- /dev/null +++ b/cloud-functions/rehearsal-centos-6-package-list/update.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +set -x +ACTION_NAME=rehearsal-centos-6-package-list +IMAGE_NAME=arjunguha/$ACTION_NAME +docker build -t $IMAGE_NAME . +docker push $IMAGE_NAME +bx wsk action update $ACTION_NAME \ No newline at end of file diff --git a/cloud-functions/rehearsal-package-server/.gitignore b/cloud-functions/rehearsal-package-server/.gitignore new file mode 100644 index 0000000..f8084ca --- /dev/null +++ b/cloud-functions/rehearsal-package-server/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/dist +/rehearsal-package-server.zip diff --git a/cloud-functions/rehearsal-package-server/README.md b/cloud-functions/rehearsal-package-server/README.md new file mode 100644 index 0000000..002563b --- /dev/null +++ b/cloud-functions/rehearsal-package-server/README.md @@ -0,0 +1,8 @@ +Initialization: + +1. Fetch dependencies: `yarn install` +2. Build: `yarn run build` +3. Create archive: `yarn run zip` +4. Initialize: `bx wsk action create rehearsal-package-server --kind:nodejs8 rehearsal-package-server.zip --web true --param apiKeyId --param serviceInstanceId ` + +To update: `yarn run build && yarn run update` \ No newline at end of file diff --git a/cloud-functions/rehearsal-package-server/bin/update.sh b/cloud-functions/rehearsal-package-server/bin/update.sh new file mode 100755 index 0000000..2ddc825 --- /dev/null +++ b/cloud-functions/rehearsal-package-server/bin/update.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -x +set -e + +./bin/zip.sh +bx wsk action update rehearsal-package-server --kind=nodejs:8 rehearsal-package-server.zip \ No newline at end of file diff --git a/cloud-functions/rehearsal-package-server/bin/zip.sh b/cloud-functions/rehearsal-package-server/bin/zip.sh new file mode 100755 index 0000000..e7d2c5d --- /dev/null +++ b/cloud-functions/rehearsal-package-server/bin/zip.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -x +set -e +zip -q -r rehearsal-package-server.zip node_modules dist package.json diff --git a/cloud-functions/rehearsal-package-server/package.json b/cloud-functions/rehearsal-package-server/package.json new file mode 100644 index 0000000..b3e8654 --- /dev/null +++ b/cloud-functions/rehearsal-package-server/package.json @@ -0,0 +1,20 @@ +{ + "name": "rehearsal-package-server", + "version": "1.0.0", + "main": "dist/index.js", + "license": "MIT", + "scripts": { + "build": "./node_modules/.bin/tsc", + "update": "./bin/update.sh", + "zip": "./bin/zip.sh" + }, + "devDependencies": { + "@types/node": "^8.5.7", + "typescript": "^2.6.2" + }, + "dependencies": { + "aws-sdk": "^2.177.0", + "ibm-cos-sdk": "^1.1.1", + "openwhisk": "^3.11.0" + } +} diff --git a/cloud-functions/rehearsal-package-server/ts/index.ts b/cloud-functions/rehearsal-package-server/ts/index.ts new file mode 100644 index 0000000..64a062d --- /dev/null +++ b/cloud-functions/rehearsal-package-server/ts/index.ts @@ -0,0 +1,49 @@ +const IBMCos = require('ibm-cos-sdk'); +// This gives compile errors. Uncomment for type completion. +// import * as IBMCos from 'ibm-cos-sdk'; +import * as Openwhisk from 'openwhisk'; + +export function main(params: any) { + console.log(JSON.stringify(params)); + const cos = new IBMCos.S3({ + endpoint: 'https://s3.us-south.objectstorage.softlayer.net', + apiKeyId: params.apiKeyId, + ibmAuthEndpoint: 'https://iam.ng.bluemix.net/oidc/token', + serviceInstanceId: params.serviceInstanceId, + }); + const ow = Openwhisk(); + + const path = params.__ow_path.split('/'); + + + if (!(path.length === 4 && + path[0] === '' && + path[1] === 'query' && + (path[2] === 'centos-6' || path[2] === 'ubuntu-trusty'))) { + return { body: `path ${path} is invalid` }; + } + + const os = path[2]; + const pkg = path[3]; + + const key = `${os}/${pkg}`; + return cos.getObject({ Bucket: 'rehearsal-cache', Key: key }).promise() + .then((value: any) => ({ body: value.Body.toString() })) + .catch((reason: any) => + ow.actions.invoke({ + name: `rehearsal-${os}-package-list`, + result: true, + blocking: true, + params: { package: pkg } + }) + .then(value => { + const files = (value.files as string[]).join('\n'); + return cos.putObject({ + Body: files, + Bucket: 'rehearsal-cache', + Key: key + }).promise() + .then(() => ({ body: files })); + })) + .catch((reason: any) => ({ body: reason })); +} \ No newline at end of file diff --git a/cloud-functions/rehearsal-package-server/tsconfig.json b/cloud-functions/rehearsal-package-server/tsconfig.json new file mode 100644 index 0000000..dec885d --- /dev/null +++ b/cloud-functions/rehearsal-package-server/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "./dist", + "allowUnreachableCode": true, + "lib": ["es2016"], + "target": "es6", + "pretty": true, + "noFallthroughCasesInSwitch": true, + "strict": true, + "noImplicitReturns": true, + "inlineSourceMap": true + }, + "include": [ + "ts" + ] +} diff --git a/cloud-functions/rehearsal-package-server/yarn.lock b/cloud-functions/rehearsal-package-server/yarn.lock new file mode 100644 index 0000000..10bb476 --- /dev/null +++ b/cloud-functions/rehearsal-package-server/yarn.lock @@ -0,0 +1,479 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node@^8.0.26", "@types/node@^8.5.7": + version "8.5.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.7.tgz#9c498c35af354dcfbca3790fb2e81129e93cf0e2" + +"@types/swagger-schema-official@^2.0.6": + version "2.0.8" + resolved "https://registry.yarnpkg.com/@types/swagger-schema-official/-/swagger-schema-official-2.0.8.tgz#b1110426002bbef298b833422d48087d44a1f05a" + +ajv@^5.1.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sdk@^2.177.0: + version "2.177.0" + resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.177.0.tgz#d5fbf1f82bab250e55153699b030b44f687f600b" + dependencies: + buffer "4.9.1" + crypto-browserify "1.0.9" + events "^1.1.1" + jmespath "0.15.0" + querystring "0.2.0" + sax "1.2.1" + url "0.10.3" + uuid "3.1.0" + xml2js "0.4.17" + xmlbuilder "4.2.1" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +base64-js@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +boom@4.x.x: + version "4.3.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + dependencies: + hoek "4.x.x" + +boom@5.x.x: + version "5.2.0" + resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + dependencies: + hoek "4.x.x" + +buffer@4.9.1: + version "4.9.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.1.tgz#6d1bb601b07a4efced97094132093027c95bc298" + dependencies: + base64-js "^1.0.2" + ieee754 "^1.1.4" + isarray "^1.0.0" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +core-util-is@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +cryptiles@3.x.x: + version "3.1.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + dependencies: + boom "5.x.x" + +crypto-browserify@1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-1.0.9.tgz#cc5449685dfb85eb11c9828acc7cb87ab5bbfcc0" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +debug@^2.1.2: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +es6-promise@^4.1.0: + version "4.2.2" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.2.tgz#f722d7769af88bd33bc13ec6605e1f92966b82d9" + +events@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" + +extend@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fast-deep-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + +har-validator@~5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + dependencies: + ajv "^5.1.0" + har-schema "^2.0.0" + +hawk@~6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + dependencies: + boom "4.x.x" + cryptiles "3.x.x" + hoek "4.x.x" + sntp "2.x.x" + +hoek@4.x.x: + version "4.2.0" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +ibm-cos-sdk@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ibm-cos-sdk/-/ibm-cos-sdk-1.1.1.tgz#1e6bd0a68771c81f95c25ad02c2ce12e0b23c33d" + dependencies: + buffer "4.9.1" + crypto-browserify "1.0.9" + es6-promise "^4.1.0" + jmespath "0.15.0" + querystring "0.2.0" + request "^2.81.0" + sax "1.1.5" + url "0.10.3" + uuid "3.0.0" + xml2js "0.4.15" + xmlbuilder "2.6.2" + +iconv-lite@^0.4.4: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +ieee754@^1.1.4: + version "1.1.8" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +isarray@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jmespath@0.15.0: + version "0.15.0" + resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +lodash@^4.0.0: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +lodash@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.5.0.tgz#19bb3f4d51278f0b8c818ed145c74ecf9fe40e6d" + +mime-db@~1.30.0: + version "1.30.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" + +mime-types@^2.1.12, mime-types@~2.1.17: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" + dependencies: + mime-db "~1.30.0" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +needle@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.1.0.tgz#54acebad9cc1a11822cd9ca522fb7c131c583fa4" + dependencies: + debug "^2.1.2" + iconv-lite "^0.4.4" + +oauth-sign@~0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +openwhisk@^3.11.0: + version "3.11.0" + resolved "https://registry.yarnpkg.com/openwhisk/-/openwhisk-3.11.0.tgz#f0a1f7fe1cacc1270b7870c6b47d4853d19773d3" + dependencies: + "@types/node" "^8.0.26" + "@types/swagger-schema-official" "^2.0.6" + needle "^2.1.0" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + +request@^2.81.0: + version "2.83.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.6.0" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.1" + forever-agent "~0.6.1" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.1.0" + +safe-buffer@^5.0.1, safe-buffer@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +sax@1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.1.5.tgz#1da50a8d00cdecd59405659f5ff85349fe773743" + +sax@1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a" + +sax@>=0.6.0: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + +sntp@2.x.x: + version "2.1.0" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" + dependencies: + hoek "4.x.x" + +sshpk@^1.7.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +stringstream@~0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +tough-cookie@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" + dependencies: + punycode "^1.4.1" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +typescript@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" + +url@0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/url/-/url-0.10.3.tgz#021e4d9c7705f21bbf37d03ceb58767402774c64" + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +uuid@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.0.tgz#6728fc0459c450d796a99c31837569bdf672d728" + +uuid@3.1.0, uuid@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +xml2js@0.4.15: + version "0.4.15" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.15.tgz#95cd03ff2dd144ec28bc6273bf2b2890c581ad0c" + dependencies: + sax ">=0.6.0" + xmlbuilder ">=2.4.6" + +xml2js@0.4.17: + version "0.4.17" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.17.tgz#17be93eaae3f3b779359c795b419705a8817e868" + dependencies: + sax ">=0.6.0" + xmlbuilder "^4.1.0" + +xmlbuilder@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-2.6.2.tgz#f916f6d10d45dc171b1be2e6e673fb6e0cc35d0a" + dependencies: + lodash "~3.5.0" + +xmlbuilder@4.2.1, xmlbuilder@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-4.2.1.tgz#aa58a3041a066f90eaa16c2f5389ff19f3f461a5" + dependencies: + lodash "^4.0.0" + +xmlbuilder@>=2.4.6: + version "9.0.4" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.4.tgz#519cb4ca686d005a8420d3496f3f0caeecca580f" diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/Dockerfile b/cloud-functions/rehearsal-ubuntu-trusty-package-list/Dockerfile new file mode 100644 index 0000000..da7f52e --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:14.04 +MAINTAINER Arjun Guha + +RUN apt-get update +RUN apt-get install -y curl apt-file +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - +RUN apt-get install -y nodejs +RUN apt-file update +COPY action /action + +ENTRYPOINT ["/usr/bin/node", "/action/js/index.js"] \ No newline at end of file diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/README.md b/cloud-functions/rehearsal-ubuntu-trusty-package-list/README.md new file mode 100644 index 0000000..e1228a0 --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/README.md @@ -0,0 +1,3 @@ +1. Install Node packages: `cd action && yarn install` +2. Create the action: `bx wsk action create rehearsal-ubuntu-trusty-package-list --docker=arjunguha/rehearsal-ubuntu-trusty-package-list` +3. To update the action: `./update.sh` \ No newline at end of file diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/.gitignore b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/.gitignore new file mode 100644 index 0000000..07e6e47 --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/js/index.js b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/js/index.js new file mode 100644 index 0000000..5320e66 --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/js/index.js @@ -0,0 +1,61 @@ +// This is based on: +// +// https://github.com/apache/incubator-openwhisk-runtime-docker/blob/master/core/actionProxy/actionproxy.py +var express = require('express'); +var bodyParser = require('body-parser'); +var cp = require('child_process'); + +var app = express(); +var jsonParser = bodyParser.json() + +var LOG_SENTINEL = 'XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX\n'; + +function complete() { + process.stdout.write(LOG_SENTINEL); + process.stderr.write(LOG_SENTINEL); +} + +// This handler receives executable source code if an action is a ZIP file +// based on this image. But, we are never going to do that. +app.post('/init', function(req, resp) { + resp.status(200).send(); +}); + +app.post('/run', jsonParser, function(req, resp) { + var packageName = req.body.value.package; + if (typeof packageName !== 'string') { + resp.status(404).send(JSON.stringify({ + error: 'expected "package" parameter' + })); + complete(); + return; + } + + var cmd = `apt-file -F list ${packageName}`; + cp.exec(cmd, + { encoding: 'utf8' }, + function(err, stdout, stderr) { + if (err !== null) { + resp.status(404).send(JSON.stringify({ + error: { + message: `error from ${cmd}`, + stdout: stdout, + stderr: stderr + } + })); + complete(); + return; + } + + // Drop the trailing newline or we get an empty string in the file list. + var files = stdout.slice(0, stdout.length - 1) // drop trailing newline + .split('\n') // one file per line + .map(x => x.split(' ', 3)[1]); // 2nd column, space delimited + resp.status(200).send(JSON.stringify({ + files: files + })); + complete(); + }); +}); + +app.listen(8080); \ No newline at end of file diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/package.json b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/package.json new file mode 100644 index 0000000..d3a3cfd --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/package.json @@ -0,0 +1,10 @@ +{ + "name": "rehearsal-ubuntu-trusty-package-list", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "body-parser": "^1.18.2", + "express": "^4.16.2" + } +} diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/yarn.lock b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/yarn.lock new file mode 100644 index 0000000..063a79e --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/action/yarn.lock @@ -0,0 +1,293 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +accepts@~1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.4.tgz#86246758c7dd6d21a6474ff084a4740ec05eb21f" + dependencies: + mime-types "~2.1.16" + negotiator "0.6.1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + +body-parser@1.18.2, body-parser@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.1" + http-errors "~1.6.2" + iconv-lite "0.4.19" + on-finished "~2.3.0" + qs "6.5.1" + raw-body "2.3.2" + type-is "~1.6.15" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + +content-disposition@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +depd@1.1.1, depd@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +encodeurl@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + +express@^4.16.2: + version "4.16.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" + dependencies: + accepts "~1.3.4" + array-flatten "1.1.1" + body-parser "1.18.2" + content-disposition "0.5.2" + content-type "~1.0.4" + cookie "0.3.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.1" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.1.0" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.2" + path-to-regexp "0.1.7" + proxy-addr "~2.0.2" + qs "6.5.1" + range-parser "~1.2.0" + safe-buffer "5.1.1" + send "0.16.1" + serve-static "1.13.1" + setprototypeof "1.1.0" + statuses "~1.3.1" + type-is "~1.6.15" + utils-merge "1.0.1" + vary "~1.1.2" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +forwarded@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + +http-errors@1.6.2, http-errors@~1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + dependencies: + depd "1.1.1" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +iconv-lite@0.4.19: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ipaddr.js@1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + +mime-db@~1.30.0: + version "1.30.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" + +mime-types@~2.1.15, mime-types@~2.1.16: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" + dependencies: + mime-db "~1.30.0" + +mime@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + +proxy-addr@~2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec" + dependencies: + forwarded "~0.1.2" + ipaddr.js "1.5.2" + +qs@6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + +raw-body@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + dependencies: + bytes "3.0.0" + http-errors "1.6.2" + iconv-lite "0.4.19" + unpipe "1.0.0" + +safe-buffer@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +send@0.16.1: + version "0.16.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" + dependencies: + debug "2.6.9" + depd "~1.1.1" + destroy "~1.0.4" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "~1.6.2" + mime "1.4.1" + ms "2.0.0" + on-finished "~2.3.0" + range-parser "~1.2.0" + statuses "~1.3.1" + +serve-static@1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719" + dependencies: + encodeurl "~1.0.1" + escape-html "~1.0.3" + parseurl "~1.3.2" + send "0.16.1" + +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + +"statuses@>= 1.3.1 < 2": + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + +statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +type-is@~1.6.15: + version "1.6.15" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.15" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" diff --git a/cloud-functions/rehearsal-ubuntu-trusty-package-list/update.sh b/cloud-functions/rehearsal-ubuntu-trusty-package-list/update.sh new file mode 100755 index 0000000..e232fd7 --- /dev/null +++ b/cloud-functions/rehearsal-ubuntu-trusty-package-list/update.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +set -x +ACTION_NAME=rehearsal-ubuntu-trusty-package-list +IMAGE_NAME=arjunguha/$ACTION_NAME +docker build -t $IMAGE_NAME . +docker push $IMAGE_NAME +bx wsk action update $ACTION_NAME \ No newline at end of file diff --git a/cloud-functions/rehearsal/Dockerfile b/cloud-functions/rehearsal/Dockerfile new file mode 100644 index 0000000..a4b5665 --- /dev/null +++ b/cloud-functions/rehearsal/Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:14.04 +MAINTAINER Arjun Guha + +RUN apt-get update -q +RUN apt-get install -yq software-properties-common apt-transport-https curl +RUN add-apt-repository ppa:webupd8team/java +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - +RUN echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823 +RUN gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 +RUN gpg -a --export E084DAB9 | sudo apt-key add - +RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections +RUN apt-get update -q +RUN apt-get install -yq nodejs oracle-java8-installer sbt unzip build-essential nodejs +RUN wget -q http://www.scala-lang.org/files/archive/scala-2.11.7.deb +RUN dpkg -i scala-2.11.7.deb +RUN rm scala-2.11.7.deb +RUN wget -O datalog.tar.gz https://sourceforge.net/projects/datalog/files/datalog/2.6/datalog-2.6.tar.gz/download +RUN tar xzf datalog.tar.gz +WORKDIR /datalog-2.6 +RUN ./configure +RUN sed -i "s/-DHAVE_LIBREADLINE=1//g" Makefile +RUN make +RUN make install +WORKDIR / +RUN rm -rf datalog-2.6 +RUN rm datalog.tar.gz +RUN wget https://github.com/Z3Prover/z3/releases/download/z3-4.4.1/z3-4.4.1-x64-ubuntu-14.04.zip +RUN unzip z3-4.4.1-x64-ubuntu-14.04.zip +RUN mv /z3-4.4.1-x64-ubuntu-14.04/bin/z3 /usr/local/bin/z3 +RUN rm -rf /z3-4.4.1-x64-ubuntu-14.04 + +COPY action /action +ENTRYPOINT ["/usr/bin/node", "/action/js/index.js"] diff --git a/cloud-functions/rehearsal/README.md b/cloud-functions/rehearsal/README.md new file mode 100644 index 0000000..7434ea1 --- /dev/null +++ b/cloud-functions/rehearsal/README.md @@ -0,0 +1,4 @@ +1. Install Node packages: `cd action && yarn install` +2. Build `rehearsal.jar` and copy it into `action/` +3. Create the action: `bx wsk action create rehearsal --docker=arjunguha/rehearsal --web=true` +4. To update the action: `./update.sh` \ No newline at end of file diff --git a/cloud-functions/rehearsal/action/.gitignore b/cloud-functions/rehearsal/action/.gitignore new file mode 100644 index 0000000..e975c16 --- /dev/null +++ b/cloud-functions/rehearsal/action/.gitignore @@ -0,0 +1,2 @@ +/node_modules +/rehearsal.jar diff --git a/cloud-functions/rehearsal/action/js/index.js b/cloud-functions/rehearsal/action/js/index.js new file mode 100644 index 0000000..3a468bf --- /dev/null +++ b/cloud-functions/rehearsal/action/js/index.js @@ -0,0 +1,50 @@ +// This is based on: +// +// https://github.com/apache/incubator-openwhisk-runtime-docker/blob/master/core/actionProxy/actionproxy.py +var express = require('express'); +var bodyParser = require('body-parser'); +var cp = require('child_process'); +var tmp = require('tmp'); +var fs = require('fs'); + +var app = express(); +var jsonParser = bodyParser.json() + +var LOG_SENTINEL = 'XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX\n'; + +function complete() { + process.stdout.write(LOG_SENTINEL); + process.stderr.write(LOG_SENTINEL); +} + +// This handler receives executable source code if an action is a ZIP file +// based on this image. But, we are never going to do that. +app.post('/init', function(req, resp) { + resp.status(200).send(); +}); + +app.post('/run', jsonParser, function(req, resp) { + var { manifest, os, pred } = req.body.value; + var tmpPath = tmp.fileSync({ suffix: '.pp' }).name; + fs.writeFileSync(tmpPath, manifest); + const result = cp.spawnSync('/usr/bin/java', + [ '-jar', 'rehearsal.jar', 'check', '--filename', tmpPath, '--os', os, + '--predicate', pred], + { encoding: 'utf8', cwd: '/action', stdio: [ 'ignore', 'pipe', 'pipe' ] }); + let body; + if (result.error !== null) { + body = result.stderr + '\n' + result.stdout; + } + else { + body = result.stdout; + } + resp.status(200).send({ + headers: { + 'Cotent-Type': 'text/plain', + }, + body: body + }); + complete(); +}) + +app.listen(8080); \ No newline at end of file diff --git a/cloud-functions/rehearsal/action/package.json b/cloud-functions/rehearsal/action/package.json new file mode 100644 index 0000000..0c2eb3d --- /dev/null +++ b/cloud-functions/rehearsal/action/package.json @@ -0,0 +1,11 @@ +{ + "name": "rehearsal", + "version": "1.0.0", + "main": "index.js", + "license": "BSD-3-Clause", + "dependencies": { + "body-parser": "^1.18.2", + "express": "^4.16.2", + "tmp": "^0.0.33" + } +} diff --git a/cloud-functions/rehearsal/action/rehearsal.conf b/cloud-functions/rehearsal/action/rehearsal.conf new file mode 100644 index 0000000..2b19c48 --- /dev/null +++ b/cloud-functions/rehearsal/action/rehearsal.conf @@ -0,0 +1,12 @@ +// The hostname and port where the package server runs +package-host = "https://openwhisk.ng.bluemix.net/api/v1/web/PLASMA_dev/default/rehearsal-package-server" +// We assume these paths are directories. It is common for manifests to +// be written with the assumption that they are directories. +assumed-directories = [ "/usr", "/bin", "/etc" ] +// Rehearsal models resources such as packages by creating fake files +// in the file system. This should be a path that no real resource affects. +model-root = "/rehearsal-metadata" +// For debugging, use z3-wrapper.sh, which logs the transcript of the Z3 session. +z3-path = "/usr/local/bin/z3" +// For debugging, use datalog-wrapper.sh, which logs the transcript of the Datalog session. +datalog-path = "/usr/local/bin/datalog" diff --git a/cloud-functions/rehearsal/action/yarn.lock b/cloud-functions/rehearsal/action/yarn.lock new file mode 100644 index 0000000..9f36159 --- /dev/null +++ b/cloud-functions/rehearsal/action/yarn.lock @@ -0,0 +1,303 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +accepts@~1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.4.tgz#86246758c7dd6d21a6474ff084a4740ec05eb21f" + dependencies: + mime-types "~2.1.16" + negotiator "0.6.1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + +body-parser@1.18.2, body-parser@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.1" + http-errors "~1.6.2" + iconv-lite "0.4.19" + on-finished "~2.3.0" + qs "6.5.1" + raw-body "2.3.2" + type-is "~1.6.15" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + +content-disposition@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +depd@1.1.1, depd@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +encodeurl@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + +express@^4.16.2: + version "4.16.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" + dependencies: + accepts "~1.3.4" + array-flatten "1.1.1" + body-parser "1.18.2" + content-disposition "0.5.2" + content-type "~1.0.4" + cookie "0.3.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.1" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.1.0" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.2" + path-to-regexp "0.1.7" + proxy-addr "~2.0.2" + qs "6.5.1" + range-parser "~1.2.0" + safe-buffer "5.1.1" + send "0.16.1" + serve-static "1.13.1" + setprototypeof "1.1.0" + statuses "~1.3.1" + type-is "~1.6.15" + utils-merge "1.0.1" + vary "~1.1.2" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +forwarded@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + +http-errors@1.6.2, http-errors@~1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + dependencies: + depd "1.1.1" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +iconv-lite@0.4.19: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ipaddr.js@1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + +mime-db@~1.30.0: + version "1.30.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" + +mime-types@~2.1.15, mime-types@~2.1.16: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" + dependencies: + mime-db "~1.30.0" + +mime@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + +proxy-addr@~2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec" + dependencies: + forwarded "~0.1.2" + ipaddr.js "1.5.2" + +qs@6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + +raw-body@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + dependencies: + bytes "3.0.0" + http-errors "1.6.2" + iconv-lite "0.4.19" + unpipe "1.0.0" + +safe-buffer@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +send@0.16.1: + version "0.16.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" + dependencies: + debug "2.6.9" + depd "~1.1.1" + destroy "~1.0.4" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "~1.6.2" + mime "1.4.1" + ms "2.0.0" + on-finished "~2.3.0" + range-parser "~1.2.0" + statuses "~1.3.1" + +serve-static@1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719" + dependencies: + encodeurl "~1.0.1" + escape-html "~1.0.3" + parseurl "~1.3.2" + send "0.16.1" + +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + +"statuses@>= 1.3.1 < 2": + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + +statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + +type-is@~1.6.15: + version "1.6.15" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.15" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" diff --git a/cloud-functions/rehearsal/update.sh b/cloud-functions/rehearsal/update.sh new file mode 100755 index 0000000..e568c70 --- /dev/null +++ b/cloud-functions/rehearsal/update.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +set -x +ACTION_NAME=rehearsal +IMAGE_NAME=arjunguha/$ACTION_NAME +docker build -t $IMAGE_NAME . +docker push $IMAGE_NAME +bx wsk action update $ACTION_NAME \ No newline at end of file diff --git a/src/main/scala/ResourceModel.scala b/src/main/scala/ResourceModel.scala index 5e26697..9868cd8 100644 --- a/src/main/scala/ResourceModel.scala +++ b/src/main/scala/ResourceModel.scala @@ -39,7 +39,7 @@ object ResourceModel { def queryPackage(distro: String, pkg: String): Option[Set[Path]] = { val resp = logTime(s"Fetching package listing for $pkg ($distro)") { - Http(s"http://${Settings.packageHost}/query/$distro/$pkg").timeout(2 * 1000, 60 * 1000).asString + Http(s"${Settings.packageHost}/query/$distro/$pkg").timeout(2 * 1000, 60 * 1000).asString } if (resp.isError) { None