diff --git a/cheats/cf.cheat b/cheats/cf.cheat new file mode 100644 index 0000000..9fcf968 --- /dev/null +++ b/cheats/cf.cheat @@ -0,0 +1,130 @@ +% cf, pcf, pivotal cloud foundry, paas + + +### Information +# Get the extended list of help +cf help -a + +# Get current version of cf +cf version + +# Get information about current org +cf org + +# Get information about current space +cf space + +# Get information about current target +cf target + +# Get list of all apps +cf apps + +# Get list of all services +cf services + +# Get list of all routes +cf routes + +# Get list of all network policies +cf network-policies + + + +### Login +# Login to your CF/PCF instance +cf login -a + +# Login to your CF/PCF instance with username and password +cf login -a -u -p + +# Login and specify target directly +cf login -a -u -p -o -s + + + +### Target +# Set target org +cf target -o + +# Set target space +cf target -o -s + + +### Application manipulation +## Information +# Get the guid of an app +cf app --guid + +# Get the status of an app +cf app + +## Status +# Start an app +cf start + +# Stop an app +cf stop + +# Restart an app +cf restart + +# Rebuild the application package and restart +cf restage + +## Deletion +# Delete an app +cf delete + +# Delete an app no prompt +cf delete -f + +# Delete an app and routes +cf delete -r + + + +### Networking - A bit slow due to filtering +# Add network policy +cf add-network-policy \ +--destination-app \ +--protocol \ +--port + +# Remove network-policy +cf remove-network-policy \ +--destination-app \ +--protocol \ +--port + + +### Services +# Bind a service to an application +cf bind-service + +# Unbind a service from an application +cf unbind-service + +# Share a service between spaces +cf share-service -o -s + +# Unshare a service from a spaces +cf unshare-service -o -s + + + +# Autocomplete variables +$ org: cf orgs | awk 'NR>3 {print}' +$ space: cf target -o "$org" > /dev/null && cf spaces | awk 'NR>3 {print $1}' +$ service: cf services | awk 'NR>3 {print $1}' | sed '/TIP:/d' +$ route: cf routes | awk 'NR>3 {if ($4 ~ /^\//){ print $2 "." $3 $4} else {print $2 "." $3}}' +$ app: cf apps | awk 'NR>4 {print $1}' + +$ add_network_source: cf apps | awk 'NR>4 {print $1}' +$ add_network_destination: cf apps | awk 'NR>4 {print $1}' | sed "/$add_network_source/d" +$ add_network_protocol: printf "tcp \nudp" + +$ remove_network_source: cf network-policies | awk 'NR>3 {print $1}' | uniq +$ remove_network_destination: cf network-policies | grep "^$remove_network_source" | awk '{print $2}' | uniq +$ remove_network_protocol: cf network-policies | grep "^$remove_network_source" | grep "$remove_network_destination" | awk '{print $3}' | uniq +$ remove_network_port: cf network-policies | grep "^$remove_network_source" | grep "$remove_network_destination" | awk '{print $4}' | uniq