forked from rut31337/order_svc
-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_catalogs.sh
executable file
·52 lines (41 loc) · 1.09 KB
/
get_catalogs.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# safety options
set -e -o pipefail
# CloudForms Out of the Browser - List accessible catalog items - Guillaume Coré <gucore@redhat.com>
ORIG="$(cd "$(dirname "$0")" || exit; pwd)"
# shellcheck source=common.sh
. "${ORIG}/common.sh"
# Dont touch from here on
usage() {
echo "Error: Usage $0 [-u <username>] [ -w <uri> ] [ -i <id> ]"
}
while getopts nu:w: FLAG; do
case $FLAG in
u) username="$OPTARG";;
w) uri="$OPTARG";;
*) usage;exit;;
esac
done
if ! command -v jq > /dev/null; then
echo >&2 "please install jq"
exit 2
fi
if [ -z "$uri" ]; then
echo >&2 -n "Enter CF URI: "
read -r uri
fi
if [ -z "$username" ]; then
echo >&2 -n "Enter CF Username: "
read -r username
fi
if [ -z "$password" ]; then
echo >&2 -n "Enter CF Password: "
stty -echo
read -r password
stty echo
echo
fi
cfget \
"${uri}/api/service_catalogs?expand=resources,service_templates" \
| jq -r '.resources[]|{name: .name, services: .service_templates.resources[].name}[]' \
| while read -r c; do read -r s; echo "${c} / ${s}"; done