Last active
March 3, 2021 11:02
-
-
Save IObert/1f2236c648c4aecdbd3e463d85c197ca to your computer and use it in GitHub Desktop.
Simple aliases to make the life of CF developers easier
This file contains hidden or 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
function checkCfStatus () { | |
if echo $(cf a 2>&1 >/dev/null) | grep -q 'The token expired\|Not logged in' $OUTPUT; then | |
cf login | |
fi | |
} | |
function preexecHook () { | |
if echo $1 | grep -q "cf "; then | |
checkCfStatus | |
fi | |
} | |
add-zsh-hook preexec preexecHook | |
wipeCFApps () { | |
checkCfStatus | |
for APP in `cf apps | tail -n +4 | awk '{ print $1}' `; do cf delete -f -r $APP; done | |
# cf delete-orphaned-routes | |
} | |
wipeCFServices () { | |
checkCfStatus | |
for SERIVCE in `cf s | tail -n +4 | awk '{ print $1}' `; do cf ds -f $SERIVCE; done | |
} | |
wipeCFServiceKeys () { | |
checkCfStatus | |
for SERIVCE in `cf s | tail -n +4 | awk '{ print $1}' ` | |
do | |
for SERIVCEKEY in `cf sk $SERIVCE | tail -n +4` | |
do | |
cf dsk -f $SERIVCE $SERIVCEKEY | |
done | |
done | |
} | |
wipeCFMtas() { | |
checkCfStatus | |
for MTA in `cf mtas | tail -n +4 | awk '{ print $1}'`; do cf undeploy $MTA --delete-services --delete-service-keys -f;done | |
} | |
removeCF () { | |
echo Going to remove all apps and services that contain \'$1\': | |
for APP in `cf apps | tail -n +5 | grep $1 | awk '{ print $1}' `; do cf delete -f -r $APP; done | |
for SERIVCE in `cf s | tail -n +4 | grep $1 | awk '{ print $1}'`; do cf ds -f $SERIVCE; done | |
} | |
CFLink () { | |
checkCfStatus | |
echo "https://"$(cf a | grep $1 | awk '{print $6}') | |
} | |
wipeCF () { | |
wipeCFServiceKeys | |
wipeCFApps | |
wipeCFServices | |
} |
I have an additional line as part of the removeCF() function to get rid of MTAs and the corresponding artefacts
bash:
for MTA in `cf mtas | tail -n +4 | awk '{ print $1}'`; do cf undeploy $MTA --delete-services --delete-service-keys -f;done
Thanks, I added this line to the file (as a new function) :)
excellent! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run
curl https://gist.githubusercontent.com/IObert/1f2236c648c4aecdbd3e463d85c197ca/raw/bd8a2373aa73f85b27f810649d7a02e84243ceca/.zhsrc >> .zhsrc
to add these aliases