-
Notifications
You must be signed in to change notification settings - Fork 27
/
addon
executable file
·97 lines (85 loc) · 2.38 KB
/
addon
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
set -eu
list() {
echo "The following addons are defined:"
echo
echo " login Log into the Cloud Foundry instance as the"
echo " admin user account. This will overwrite local"
echo " cf CLI configuration!"
echo
echo " setup-cli Installs cf CLI plugins like 'Targets', which"
echo " helps to manage multiple Cloud Foundries from a"
echo " single jumpbox."
echo
echo " smoketest Run the smoke tests errand on the first vm in the"
echo " api instance group."
}
login() {
if ! cf plugins | grep -q '^cf-targets'; then
describe "#Y{The cf-targets plugin does not seem to be installed}"
echo "Install it first, via 'genesis do $GENESIS_ENVIRONMENT -- setup-cli'"
exit 1
fi
base="$(lookup params.base_domain)"
system_domain="$(lookup --exodus system_domain "system.$base")"
api_url=https://api.$system_domain
username="$(exodus admin_username)"
password="$(exodus admin_password)"
#TODO enfoce ssl validation
cf api "$api_url" --skip-ssl-validation
cf auth "$username" "$password"
cf save-target -f "$GENESIS_ENVIRONMENT"
echo ; echo
cf target
}
case $GENESIS_ADDON_SCRIPT in
list)
list
exit 0
;;
login)
login
exit 0
;;
remigrate)
# Migrate the secrets
set -e
#shellcheck disable=SC1091
source ./hooks/migrate-to-2.0
validate_expected_vault_secrets
correct_x509_certs
migrate_credentials_to_credhub
;;
setup-cli)
force=0
while test $# -gt 0 ; do
case "$1" in
-f) force=1;;
-*) describe "#R{[ERROR]} Bad option $1: expecting -f" && exit 1 ;;
*) describe "#R{[ERROR]} setup-cli does not take any arguments" && exit 1;;
esac
shift
done
if ! cf list-plugin-repos | grep -q CF-Community; then
describe 'Adding #G{Cloud Foundry Community} plugins repository...'
cf add-plugin-repo CF-Community http://plugins.cloudfoundry.org
fi
if ! cf plugins | grep -q '^cf-targets'; then
describe 'Installing the #C{cf-targets} plugin...'
cmd=( cf install-plugin -r CF-Community Targets )
if [[ "$force" == "1" ]] ; then
cmd+=( -f )
fi
"${cmd[@]}"
fi
cf plugins
;;
smoketest)
"$GENESIS_BOSH_COMMAND" -e "$BOSH_ENVIRONMENT" -d "$BOSH_DEPLOYMENT" run-errand smoke_tests
;;
*)
echo "Unrecognized Cloud Foundry Genesis Kit addon."
list
exit 1
;;
esac