Last active
April 17, 2020 13:06
-
-
Save MChorfa/4a7a941cc9d8cbf45b3d9076253d107b to your computer and use it in GitHub Desktop.
porter-verify-instance-status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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