0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-25 00:58:53 +01:00
mongodb/evergreen/external_auth_gcp_teardown.sh
Adam Rayner 5da8f18c36 SERVER-86820 Clean up Azure and Okta integration test artifacts
GitOrigin-RevId: dbd2bee4c37e5ab05c9aff19b6dc8a96617c4ca5
2024-03-18 23:08:26 +00:00

34 lines
1.2 KiB
Bash
Executable File

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
. "$DIR/prelude.sh"
cd src
activate_venv
set -o errexit
# Only run this script for the external_auth_oidc_gcp task.
if [ "${task_name}" != "external_auth_oidc_gcp" ]; then
exit 0
fi
echo "Cleaning up OIDC GCP test artifacts"
# Delete the GCP VM specified in gce_vm_info.json if GOOGLE_APPLICATION_CREDENTIALS is set, points
# to a file, and the GCE config and VM info files exist.
if [ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" ] \
&& [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ] \
&& [ -f "${HOME}/gce_vm_config.json" ] \
&& [ -f "${HOME}/gce_vm_info.json" ]; then
# Install google-cloud-compute so that the script can run.
$python -m pip install google-cloud-compute
$python src/mongo/db/modules/enterprise/jstests/external_auth_oidc_gcp/lib/gce_vm_manager.py delete --config_file $HOME/gce_vm_config.json --service_account_key_file ${GOOGLE_APPLICATION_CREDENTIALS} --output_file $HOME/gce_vm_info.json
fi
# Clean up the SSH and service account keys if they exist.
if [ -f "${HOME}/gcp_ssh_key" ]; then
rm -f $HOME/gcp_ssh_key
fi
if [ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" ] && [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
rm -f ${GOOGLE_APPLICATION_CREDENTIALS}
fi