-
Notifications
You must be signed in to change notification settings - Fork 3
/
list.sh
executable file
·55 lines (41 loc) · 1.15 KB
/
list.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
53
54
55
#!/usr/bin/env bash
set -eu
set -o pipefail
readonly PROGDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function main() {
local vm_name
local service_account_json
while [[ "${#}" != 0 ]]; do
case "${1}" in
--help|-h)
usage
exit 0
;;
--service-account-json|-s)
service_account_json="${2}"
shift 2
;;
*)
usage
echo "unknown argument \"${1}\""
exit 1
esac
done
workstation::list "${service_account_json}"
}
function usage() {
cat <<-USAGE
list.sh [OPTIONS]
OPTIONS
--help, -h prints the command usage
--service-account-json, -s <path/to/service/account/json> path to gcp service account json to authenticate with
USAGE
}
function workstation::list(){
local service_account_json
service_account_json="${1}"
gcloud auth activate-service-account --key-file="${service_account_json}"
printf "You can ssh onto the following vms:\n"
gsutil ls "gs://cf-buildpacks-workstations/" | xargs -I{} echo {} | cut -d'/' -f4
}
main "${@:-}"