This is an automated email from the ASF dual-hosted git repository.
chetanm pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-openwhisk-apigateway.git
The following commit(s) were added to refs/heads/master by this push:
new c064b29 Enable overriding the backend url to enable standalone mode
(#347)
c064b29 is described below
commit c064b29e84e706a5ce9d014f7496f2c56de0df0b
Author: Chetan Mehrotra <[email protected]>
AuthorDate: Mon Jul 29 17:24:01 2019 +0530
Enable overriding the backend url to enable standalone mode (#347)
* Fix broken building by updating the opm version
* Enable override of backend url via env
* Run code scan before installing deps
* run busted in test directory
* Update ngx var also
* Use nightly tag for controller and invoker docker images
* Make script executable
* Terminate early in case of error in scan
* Reorder steps
* Add EOL
---
.travis.yml | 1 +
Dockerfile | 2 +-
api-gateway.conf | 1 +
scripts/lua/policies/backendRouting.lua | 14 ++++++++++++++
tools/travis/build.sh | 8 +-------
tools/travis/{setup.sh => scan.sh} | 31 ++++++++++---------------------
tools/travis/setup.sh | 4 ----
7 files changed, 28 insertions(+), 33 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index ea9c497..42a8d25 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,6 +40,7 @@ env:
- secure:
"dM0paMW2d4U4U7OwbnrTjdOqDnvo+nce9r7h+qTbYfbuJe0fpRkHCrxcB//8ESkMrPTr0EDExCxvaywY8pqeVVJbykNswdyze1SWYk6lbUvXTpSrKqp0J0a/FtVjfamc1aMv4c6KIDKh4vIcgK4xrjXj68COCS6uIcFhETNUy5bxH8T2BOJzyf/iWOF7oduXUV/VGNcWnhkPdoPh8xtpmBJ6ZTWQ01MriZ/28hvzgyh1OjJFWCJZ+OZoIDQVPb/jnfPXU4Wk/G/LEPJcBgvN4qSMr2lm3Iq29V0Ltrsx8rrYADO7trCm6qyEQK9TLKfywaYIcm/D9FJ8F4WBHtIeJ3PLY3518L3iZ+Ngd6QTnd0FI6hrG7rpoD/0dz4e//9d3tSsjbh/1BiQwXXTnPyaUjN3C92k4GyITYJTVL5f6evzsTneT6Plj1vWC0E52d1oqVOZDgrWMYZEHdYvpUJTQqclMNhu5
[...]
before_install:
+ - ./tools/travis/scan.sh
- ./tools/travis/setup.sh
- pip install hererocks --user
- hererocks lua_install -r^ --$LUA
diff --git a/Dockerfile b/Dockerfile
index 47dd8e1..f123be4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -40,7 +40,7 @@ RUN apk update && \
ENV OPENRESTY_VERSION=1.13.6.2 \
PCRE_VERSION=8.37 \
TEST_NGINX_VERSION=0.24 \
- OPM_VERSION=0.0.3 \
+ OPM_VERSION=0.0.5 \
LUA_RESTY_HTTP_VERSION=0.10 \
LUA_RESTY_IPUTILS_VERSION=0.2.1 \
LUA_RESTY_STRING_VERSION=0.09 \
diff --git a/api-gateway.conf b/api-gateway.conf
index ddcea92..ad2ef40 100644
--- a/api-gateway.conf
+++ b/api-gateway.conf
@@ -29,6 +29,7 @@ env PUBLIC_MANAGEDURL_PORT;
env PUBLIC_GATEWAY_URL;
env HOST;
env PORT;
+env BACKEND_HOST;
env OPTIMIZE;
env APPID_PKURL;
diff --git a/scripts/lua/policies/backendRouting.lua
b/scripts/lua/policies/backendRouting.lua
index 17cdc34..8ef79e5 100644
--- a/scripts/lua/policies/backendRouting.lua
+++ b/scripts/lua/policies/backendRouting.lua
@@ -22,6 +22,7 @@ local url = require "url"
local utils = require "lib/utils"
local request = require "lib/request"
local logger = require "lib/logger"
+local backendOverride = os.getenv("BACKEND_HOST")
local _M = {}
@@ -39,6 +40,19 @@ function _M.setRoute(backendUrl, gatewayPath)
ngx.req.set_uri(getUriPath(u.path))
end
ngx.var.backendUrl = backendUrl
+
+ -- if there is a backend override then use that instead of actual backend
from swagger
+ if backendOverride ~= nil then
+ local bou = url.parse(backendOverride)
+ u.scheme = bou.scheme
+ u:setAuthority(bou.authority)
+
+ -- update the copy in ngx var also to match upstream
+ local bu = url.parse(backendUrl)
+ bu.scheme = bou.scheme
+ bu:setAuthority(bou.authority)
+ ngx.var.backendUrl = bu:build()
+ end
setUpstream(u)
end
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
index fa6f985..a517275 100755
--- a/tools/travis/build.sh
+++ b/tools/travis/build.sh
@@ -23,19 +23,13 @@ SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
ROOTDIR="$SCRIPTDIR/../.."
HOMEDIR="$ROOTDIR/.."
WHISKDIR="$HOMEDIR/openwhisk"
-UTILDIR="$HOMEDIR/incubator-openwhisk-utilities"
# Set Environment
export OPENWHISK_HOME=$WHISKDIR
-# run scancode util. against project source using the ASF strict configuration
-# exclude two bundled files from other open source projects that are MIT
licensed
-cd $UTILDIR
-scancode/scanCode.py --config scancode/ASF-Release.cfg --gitignore
$SCRIPTDIR/scancodeExclusions $ROOTDIR
-
# Install OpenWhisk
cd $OPENWHISK_HOME/ansible
-ANSIBLE_CMD="ansible-playbook -i environments/local -e
docker_image_prefix=openwhisk"
+ANSIBLE_CMD="ansible-playbook -i environments/local -e
docker_image_prefix=openwhisk -e docker_image_tag=nightly"
$ANSIBLE_CMD setup.yml
$ANSIBLE_CMD prereq.yml
diff --git a/tools/travis/setup.sh b/tools/travis/scan.sh
similarity index 55%
copy from tools/travis/setup.sh
copy to tools/travis/scan.sh
index 27d7b10..ad16bc2 100755
--- a/tools/travis/setup.sh
+++ b/tools/travis/scan.sh
@@ -16,30 +16,19 @@
# limitations under the License.
#
-SCRIPTDIR=$(cd $(dirname "$0") && pwd)
-HOMEDIR="$SCRIPTDIR/../../.."
+set -ex
-sudo gpasswd -a travis docker
-sudo -E bash -c 'echo '\''DOCKER_OPTS="-H tcp://0.0.0.0:4243 -H
unix:///var/run/docker.sock --storage-driver=overlay
--userns-remap=default"'\'' > /etc/default/docker'
-
-# Docker
-sudo apt-get -y update -qq
-sudo apt-get -o Dpkg::Options::="--force-confold" --force-yes -y install
docker-engine=1.12.0-0~trusty
-sudo service docker restart
-echo "Docker Version:"
-docker version
-echo "Docker Info:"
-docker info
-
-# jshint support
-sudo apt-get -y install nodejs npm
-sudo npm install -g jshint
+# Build script for Travis-CI.
+SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
+ROOTDIR="$SCRIPTDIR/../.."
+HOMEDIR="$ROOTDIR/.."
+UTILDIR="$HOMEDIR/incubator-openwhisk-utilities"
# clone OpenWhisk utilities repo. in order to run scanCode
cd $HOMEDIR
git clone https://github.com/apache/incubator-openwhisk-utilities.git
-# clone main openwhisk repo. for testing purposes
-git clone --depth=1 https://github.com/apache/incubator-openwhisk.git openwhisk
-cd openwhisk
-./tools/travis/setup.sh
+# run scancode util. against project source using the ASF strict configuration
+# exclude few bundled files from other open source projects that are MIT
licensed
+cd "$UTILDIR"
+scancode/scanCode.py --config scancode/ASF-Release.cfg --gitignore
"$SCRIPTDIR/scancodeExclusions" "$ROOTDIR"
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
index 27d7b10..45e866d 100755
--- a/tools/travis/setup.sh
+++ b/tools/travis/setup.sh
@@ -34,11 +34,7 @@ docker info
# jshint support
sudo apt-get -y install nodejs npm
sudo npm install -g jshint
-
-# clone OpenWhisk utilities repo. in order to run scanCode
cd $HOMEDIR
-git clone https://github.com/apache/incubator-openwhisk-utilities.git
-
# clone main openwhisk repo. for testing purposes
git clone --depth=1 https://github.com/apache/incubator-openwhisk.git openwhisk
cd openwhisk