Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of edge cases #18

Merged
merged 4 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pscale/cli-helper-scripts/ps-create-helper-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function create-deployment {
echo "Check out the deploy request status at $deploy_request"
exit 5
else
echo "Check out the deploy request merged at $deploy_request"
echo "Check out the deploy request at $deploy_request"
fi

}
9 changes: 7 additions & 2 deletions .pscale/cli-helper-scripts/set-db-and-org-and-branch-name.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@

# Set DB_NAME unless it is already set
export DB_NAME=${DB_NAME:-example-db-${GITHUB_USER}}
export DB_NAME=${DB_NAME:-harry-potter-${GITHUB_USER:-db}}
echo "Using DB name ${DB_NAME}"

# set org name to first org the user has access to unless it is already set in ORG_NAME
if [ -z "${ORG_NAME}" ]; then
export ORG_NAME=`pscale org list --format json | jq -r ".[0].name"`
# check exit code and name of the org
# check exit code
if [ $? -ne 0 ] || [ -z "${ORG_NAME}" ]; then
echo "Error: Failed to get PlanetScale org name, please set ORG_NAME explicitly or use Web based SSO, service tokens do not allow to list orgs."
exit 1
fi
# if org name is set to planetscale, we will set org name to planetscale-demo instead
if [ "${ORG_NAME}" = "planetscale" ]; then
export ORG_NAME="planetscale-demo"
fi
fi

echo "Using org name ${ORG_NAME}"

export BRANCH_NAME=${BRANCH_NAME:-"main"}
Expand Down
2 changes: 1 addition & 1 deletion .pscale/cli-helper-scripts/set-db-and-org-name.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Set DB_NAME unless it is already set
export DB_NAME=${DB_NAME:-matrix-demos-${GITHUB_USER}}
export DB_NAME=${DB_NAME:-example-db-${GITHUB_USER}}
# Set org name unless it is already set
export ORG_NAME=${ORG_NAME:-"planetscale-demo"}
8 changes: 4 additions & 4 deletions .pscale/cli-helper-scripts/wait-for-deploy-request-merged.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ function wait_for_deploy_request_merged {
echo "Deploy request $number is not ready after $retries retries. Exiting..."
return 2
fi
echo "Deploy-request $number is not merged yet. Current status:"
echo "Deploy-request $number is not deployed yet. Current status:"
echo "show vitess_migrations\G" | pscale shell "$db" main --org "$org"
echo "Retrying in $wait seconds..."
sleep $wait
elif [ "$output" = "\"complete\"" ]; then
echo "Deploy-request $number has been merged successfully."
elif [ "$output" = "\"complete\"" ] || [ "$output" = "\"complete_pending_revert\"" ]; then
echo "Deploy-request $number has been deployed successfully."
return 0
else
echo "Deploy-request $number with unknown status: $output"
return 3
fi
done
}
}