forked from cloud-gov/cg-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-all-cf-deployers.sh
executable file
·32 lines (27 loc) · 1.04 KB
/
get-all-cf-deployers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
CI_URL="${CI_URL:-"https://ci.fr.cloud.gov"}"
FLY_TARGET=$(fly targets | grep "${CI_URL}" | head -n 1 | awk '{print $1}')
if ! fly --target "${FLY_TARGET}" workers > /dev/null; then
echo "Not logged in to concourse"
exit 1
fi
pipelines=$(fly --target "$FLY_TARGET" pipelines | grep -Eo '^[a-z0-9\-]+')
echo "Checking pipelines for CF users"
echo "Total pipelines flown ${CI_URL}: $( echo "$pipelines" | wc -w )"
for pipeline in $pipelines
do
match=$(
fly --target "$FLY_TARGET" get-pipeline --pipeline "$pipeline" | \
spruce json | \
jq -e '.resources[] | select( .type == "cf" ) | .source'
)
if [ "$?" -eq 0 ]
then
echo
echo "Found CF user in fly --target ${FLY_TARGET} get-pipeline --pipeline ${pipeline}"
echo " operator login commands: "
echo "${match}" | jq -r '" cf login --sso -a \(.api) -o \(.organization) -s \(.space)"'
echo " deployer login commands: "
echo "${match}" | jq -r '" cf login -a \(.api) -u \(.username) -p '\''\(.password)'\'' -o \(.organization) -s \(.space)"'
fi
done