Skip to content

Instantly share code, notes, and snippets.

@MChorfa
Last active April 17, 2020 13:06
Show Gist options
  • Save MChorfa/4a7a941cc9d8cbf45b3d9076253d107b to your computer and use it in GitHub Desktop.
Save MChorfa/4a7a941cc9d8cbf45b3d9076253d107b to your computer and use it in GitHub Desktop.
porter-verify-instance-status
#!/usr/bin/env bash
set -euo pipefail
# USAGE: ./porter-verify.sh instanceStatus 'YOUR_BUNDLE_NAME'
function instanceStatus() {
# Define success constant
local STATUS_SUCCESS="SUCCESS"
# bundle name argument
local instanceName=$1
# Locals
local instanceResult=""
local status=""
# Get instance result
instanceResult=$(porter instance show "$instanceName" -o json | jq -r '.result')
# Get the latest action status
status=$(echo "$instanceResult" | jq -r '.status' | awk '{ print toupper($0); }')
# check status
if [[ $STATUS_SUCCESS == "$status" ]]; then
echo "$status"
exit 0
else
message=$(echo "$instanceResult" | jq -r '.message')
echo "Status: $status"
echo "Message: $message"
exit 1
fi
}
# Call the requested function and pass the arguments as-is
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment