Skip to content

Commit

Permalink
Merge pull request #15 from HugoByte/hotfix/refactor-deploy-script
Browse files Browse the repository at this point in the history
[Hotfix] Refactor deploy script
  • Loading branch information
MuhammedIrfan authored Sep 26, 2021
2 parents c5d5c7b + e52ce2c commit 0c7ee00
Show file tree
Hide file tree
Showing 16 changed files with 209 additions and 368 deletions.
50 changes: 13 additions & 37 deletions actions/balance-filter/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,22 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001}
openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP}
openwhiskNamespace=${openwhiskNamespace:-guest}
actionHome=${actionHome:-actions/balance-filter}
WSK_CLI="wsk"
DOCKER_IMAGE="hugobyte/openwhisk-runtime-rust:v0.2"
if ! command -v $WSK_CLI &> /dev/null
then
echo "wsk cli not found in path. Please get the cli from https://github.com/apache/openwhisk-cli/releases"
exit
fi
ACTION="balance-filter"
PACKAGE_HOME="$PWD/${actionHome}/temp/$ACTION"

while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="${2%/}"
fi

shift
done

set -e

cd "$PWD/$actionHome"
ACTION="balance-filter"
ACTION_TYPE="rust"
SCRIPTS_DIR="$PWD/scripts"
SRC_DIR="$PWD/${actionHome}"
TEMP_DIR="$PWD/${actionHome}/temp"

if [ -e ./temp/${ACTION} ]; then
echo "Clearing previously packed action file."
rm -rf ./temp/${ACTION}
fi
source "$SCRIPTS_DIR/accept_params.sh"
source "$SCRIPTS_DIR/check_dependencies.sh"
source "$SCRIPTS_DIR/build_action.sh"

mkdir -p ./temp/${ACTION}
echo "Creating temporary directory"
echo "$PACKAGE_HOME/main.zip"
echo "Building Source"
zip -r - Cargo.toml src | docker run -i --rm ${DOCKER_IMAGE} -compile main > "$PACKAGE_HOME/main.zip"
check wsk

cd ./temp/${ACTION}
build

$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$PACKAGE_HOME/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" --param push_notification_trigger "send-push-notification" --param db_url "http://admin:p@[email protected]:5984" --param db_name "balance_filter_db" -a provide-api-key true
$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" --param push_notification_trigger "send-push-notification" --param db_url "http://admin:p@[email protected]:5984" --param db_name "balance_filter_db" -a provide-api-key true

if [ -e ./temp/${ACTION} ]; then
echo "Clearing temporary packed action file."
rm -rf ./temp/${ACTION}
fi
clear_temp
50 changes: 13 additions & 37 deletions actions/balance-notification-registration/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,22 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001}
openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP}
openwhiskNamespace=${openwhiskNamespace:-guest}
actionHome=${actionHome:-actions/balance-notification-registration}
WSK_CLI="wsk"
DOCKER_IMAGE="hugobyte/openwhisk-runtime-rust:v0.2"
if ! command -v $WSK_CLI &> /dev/null
then
echo "wsk cli not found in path. Please get the cli from https://github.com/apache/openwhisk-cli/releases"
exit
fi
ACTION="balance-notification-registration"
PACKAGE_HOME="$PWD/${actionHome}/temp/$ACTION"

while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="${2%/}"
fi

shift
done

set -e

cd "$PWD/$actionHome"
ACTION="balance-notification-registration"
ACTION_TYPE="rust"
SCRIPTS_DIR="$PWD/scripts"
SRC_DIR="$PWD/${actionHome}"
TEMP_DIR="$PWD/${actionHome}/temp"

if [ -e ./temp/${ACTION} ]; then
echo "Clearing previously packed action file."
rm -rf ./temp/${ACTION}
fi
source "$SCRIPTS_DIR/accept_params.sh"
source "$SCRIPTS_DIR/check_dependencies.sh"
source "$SCRIPTS_DIR/build_action.sh"

mkdir -p ./temp/${ACTION}
echo "Creating temporary directory"
echo "$PACKAGE_HOME/main.zip"
echo "Building Source"
zip -r - Cargo.toml src | docker run -e RELEASE=true -i --rm ${DOCKER_IMAGE} -compile main > "$PACKAGE_HOME/main.zip"
check wsk

cd ./temp/${ACTION}
build

$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$PACKAGE_HOME/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" --param event_registration_db "event_registration_db" --param balance_filter_db "balance_filter_db" --param db_name "balance_notification_registration_db" --param db_url "http://admin:p@[email protected]:5984" --web true
$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" --param event_registration_db "event_registration_db" --param balance_filter_db "balance_filter_db" --param db_name "balance_notification_registration_db" --param db_url "http://admin:p@[email protected]:5984" --web true

if [ -e ./temp/${ACTION} ]; then
echo "Clearing temporary packed action file."
rm -rf ./temp/${ACTION}
fi
clear_temp
28 changes: 7 additions & 21 deletions actions/event-producer/deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,13 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001}
openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP}
openwhiskNamespace=${openwhiskNamespace:-guest}
actionHome=${actionHome:-actions/event-producer}
WSK_CLI="wsk"
if ! command -v $WSK_CLI &> /dev/null
then
echo "wsk cli not found in path. Please get the cli from https://github.com/apache/openwhisk-cli/releases"
exit
fi
ACTION="event-producer"

while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="${2%/}"
fi

shift
done

set -e

cd "$PWD/$actionHome"
ACTION="event-producer"
SCRIPTS_DIR="$PWD/scripts"
SRC_DIR="$PWD/${actionHome}"

source "$SCRIPTS_DIR/accept_params.sh"
source "$SCRIPTS_DIR/check_dependencies.sh"

$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$PWD/event-producer.py" \
--auth "$openwhiskApiKey"
$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$SRC_DIR/event-producer.py" \
--auth "$openwhiskApiKey"
50 changes: 13 additions & 37 deletions actions/event-receiver/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,22 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001}
openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP}
openwhiskNamespace=${openwhiskNamespace:-guest}
actionHome=${actionHome:-actions/event-receiver}
WSK_CLI="wsk"
DOCKER_IMAGE="hugobyte/openwhisk-runtime-rust:v0.2"
if ! command -v $WSK_CLI &> /dev/null
then
echo "wsk cli not found in path. Please get the cli from https://github.com/apache/openwhisk-cli/releases"
exit
fi
ACTION="event-receiver"
PACKAGE_HOME="$PWD/${actionHome}/temp/event-receiver"

while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="${2%/}"
fi

shift
done

set -e

cd "$PWD/$actionHome"

if [ -e ./temp/${ACTION} ]; then
echo "Clearing previously packed action file."
rm -rf ./temp/${ACTION}
fi
ACTION="event-receiver"
ACTION_TYPE="rust"
SCRIPTS_DIR="$PWD/scripts"
SRC_DIR="$PWD/${actionHome}"
TEMP_DIR="$PWD/${actionHome}/temp"

mkdir -p ./temp/${ACTION}
echo "Creating temporary directory"
source "$SCRIPTS_DIR/accept_params.sh"
source "$SCRIPTS_DIR/check_dependencies.sh"
source "$SCRIPTS_DIR/build_action.sh"

echo "Building Source"
zip -r - Cargo.toml src | docker run -e RELEASE=true -i --rm ${DOCKER_IMAGE} -compile main > "$PACKAGE_HOME/main.zip"
check wsk

cd ./temp/${ACTION}
build

$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$PACKAGE_HOME/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" -a provide-api-key true
$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" -a provide-api-key true

if [ -e ./temp/${ACTION} ]; then
echo "Clearing temporary packed action file."
rm -rf ./temp/${ACTION}
fi
clear_temp
50 changes: 13 additions & 37 deletions actions/event-registration/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,22 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001}
openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP}
openwhiskNamespace=${openwhiskNamespace:-guest}
actionHome=${actionHome:-actions/event-registration}
WSK_CLI="wsk"
DOCKER_IMAGE="hugobyte/openwhisk-runtime-rust:v0.2"
if ! command -v $WSK_CLI &> /dev/null
then
echo "wsk cli not found in path. Please get the cli from https://github.com/apache/openwhisk-cli/releases"
exit
fi
ACTION="event-registration"
PACKAGE_HOME="$PWD/${actionHome}/temp/$ACTION"

while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="${2%/}"
fi

shift
done

set -e

cd "$PWD/$actionHome"
ACTION="event-registration"
ACTION_TYPE="rust"
SCRIPTS_DIR="$PWD/scripts"
SRC_DIR="$PWD/${actionHome}"
TEMP_DIR="$PWD/${actionHome}/temp"

if [ -e ./temp/${ACTION} ]; then
echo "Clearing previously packed action file."
rm -rf ./temp/${ACTION}
fi
source "$SCRIPTS_DIR/accept_params.sh"
source "$SCRIPTS_DIR/check_dependencies.sh"
source "$SCRIPTS_DIR/build_action.sh"

mkdir -p ./temp/${ACTION}
echo "Creating temporary directory"
echo "$PACKAGE_HOME/main.zip"
echo "Building Source"
zip -r - Cargo.toml src | docker run -e RELEASE=true -i --rm ${DOCKER_IMAGE} -compile main > "$PACKAGE_HOME/main.zip"
check wsk

cd ./temp/${ACTION}
build

$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$PACKAGE_HOME/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" --param db_name "event_registration_db" --param db_url "http://admin:p@[email protected]:5984" --param feed "kafka-provider-feed" --param brokers "[\"172.17.0.1:9092\"]" -a provide-api-key true
$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \
--auth "$openwhiskApiKey" --param db_name "event_registration_db" --param db_url "http://admin:p@[email protected]:5984" --param feed "kafka-provider-feed" --param brokers "[\"172.17.0.1:9092\"]" -a provide-api-key true

if [ -e ./temp/${ACTION} ]; then
echo "Clearing temporary packed action file."
rm -rf ./temp/${ACTION}
fi
clear_temp
54 changes: 13 additions & 41 deletions actions/kafka-provider-feed/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,22 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001}
openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP}
openwhiskNamespace=${openwhiskNamespace:-guest}
actionHome=${actionHome:-actions/kafka-provider-feed}
WSK_CLI="wsk"
if ! command -v $WSK_CLI &> /dev/null
then
echo "wsk cli not found in path. Please get the cli from https://github.com/apache/openwhisk-cli/releases"
exit
fi
ACTION="kafka-provider-feed"
PACKAGE_HOME="$PWD/${actionHome}/temp/$ACTION"

while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="${2%/}"
fi

shift
done

set -e

cd "$PWD/$actionHome"

if [ -e ./temp/${ACTION} ]; then
echo "Clearing previously packed action file."
rm -rf ./temp/${ACTION}
fi

mkdir -p ./temp/${ACTION}
echo "Creating temporary directory"


cp -r ./package.json ./lib ./main.js ./temp/${ACTION}
echo "Copying files to temporary directory"
ACTION="kafka-provider-feed"
ACTION_TYPE="js"
SCRIPTS_DIR="$PWD/scripts"
SRC_DIR="$PWD/${actionHome}"
TEMP_DIR="$PWD/${actionHome}/temp"

cd ./temp/${ACTION}
source "$SCRIPTS_DIR/accept_params.sh"
source "$SCRIPTS_DIR/check_dependencies.sh"
source "$SCRIPTS_DIR/build_action.sh"

yarn install --production=true
check wsk

zip -r main.zip *
build

$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$PACKAGE_HOME/main.zip" --kind nodejs:default \
--auth "$openwhiskApiKey" -a feed true --param endpoint "http://172.17.0.1:8888" --param web_action "kafka-provider-web" -a provide-api-key true
$WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --kind nodejs:default \
--auth "$openwhiskApiKey" -a feed true --param endpoint "http://172.17.0.1:8888" --param web_action "kafka-provider-web" -a provide-api-key true

if [ -e ./temp/${ACTION} ]; then
echo "Clearing temporary packed action file."
rm -rf ./temp/${ACTION}
fi
clear_temp
Loading

0 comments on commit 0c7ee00

Please sign in to comment.