Last active
December 12, 2017 22:15
-
-
Save m-richo/67fc0fae82c8fda484d3dfeabc5899be to your computer and use it in GitHub Desktop.
Revisions
-
m-richo revised this gist
Oct 4, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -25,8 +25,8 @@ do do SPACE_NAME=$(cf curl /v2/spaces/$SPACE_GUID |jq -r '.entity.name') SPACE_APP_NUMBER=$(cf curl /v2/spaces/$SPACE_GUID/apps |jq -r '.total_results') DEVELOPERS=$(cf curl /v2/spaces/$SPACE_GUID/developers | jq -r '.resources[] .entity.username' |tr '\n' ' ') echo "CF SPACE = $SPACE_NAME - $SPACE_APP_NUMBER app(s)" # Iterate through all the CF apps in this CF space -
m-richo created this gist
Oct 4, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #!/bin/bash set -eu set -o pipefail API_ENDPOINT=$(cf api |grep "endpoint" |awk -F "https://" '{print $2}') rm -f $API_ENDPOINT.csv echo "Running audit for $API_ENDPOINT" echo "Output is in $API_ENDPOINT.csv" echo "ORG_NAME,SPACE_NAME,APP_NAME,DEVELOPERS" > $API_ENDPOINT.csv # List of all CF Orgs and then iterate through them ORG_GUIDS=$(cf curl /v2/organizations | jq -r '.resources[] .metadata.guid') for ORG_GUID in $ORG_GUIDS do ORG_NAME=$(cf curl /v2/organizations/$ORG_GUID |jq -r '.entity.name') echo "CF ORG = $ORG_NAME" # Iterate through all the CF spaces in this CF ORG SPACE_GUIDS=$(cf curl /v2/organizations/$ORG_GUID/spaces |jq -r '.resources[] .metadata.guid') for SPACE_GUID in $SPACE_GUIDS do SPACE_NAME=$(cf curl /v2/spaces/$SPACE_GUID |jq -r '.entity.name') SPACE_APP_NUMBER=$(cf curl /v2/spaces/$SPACE_GUID/apps |jq -r '.total_results') DEVELOPERS=$(cf curl /v2/spaces/$SPACE_GUID/developers | jq -r '.resources[] .entity.username' |tr '\n' ' ') echo "CF SPACE = $SPACE_NAME - $SPACE_APP_NUMBER app(s)" # Iterate through all the CF apps in this CF space APP_GUIDS=$(cf curl /v2/spaces/$SPACE_GUID/apps | jq -r '.resources[] .metadata.guid') for APP_GUID in $APP_GUIDS do APP_NAME=$(cf curl /v2/apps/$APP_GUID |jq -r '.entity.name') echo "$ORG_NAME,$SPACE_NAME,$APP_NAME,$DEVELOPERS" >> $API_ENDPOINT.csv done done echo "" done