Skip to content

Instantly share code, notes, and snippets.

@devicezero
Last active February 1, 2021 14:37
Show Gist options
  • Save devicezero/f94c6e9fc5eb70de74260f068cdd0482 to your computer and use it in GitHub Desktop.
Save devicezero/f94c6e9fc5eb70de74260f068cdd0482 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage: e.g. delete-user.sh '[email protected]'
# get project list
projects_list=$(platform project:list --pipe)
# transform into an array, so we can loop over projects
projects=($projects_list)
# first command line option of this script is the email adress of the user we want to remove
email=$1
# loop over the projects
for i in "${!projects[@]}"; do
# check if email exists in project
results=$(platform user:list -p "${projects[$i]}" --no-header --columns=email,id --format=tsv | grep -c "$email")
# if email exists, remove from project
if [ "$results" -ge 1 ]
then
echo "deleting $email from ${projects[$i]}"
platform user:delete -p "${projects[$i]}" --no-wait -y "$email"
# after a user is removed, environment(s) need to be redeployed, e.g. for master:
# platform redeploy -p ${projects[$i]} -e master
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment