-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgcloud
executable file
·43 lines (35 loc) · 1.09 KB
/
gcloud
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
#!/usr/bin/env bash
dir=$(cd $(dirname "$0") && pwd)
source $dir/variables.sh
config_container="$GCLOUD_PROJECT""-gcloud-config"
if [[ "$1" = "reauth" ]] ; then
docker rm -v -f $config_container
fi
if [[ "$@" == "bash" ]] ; then
TO_RUN="bash"
elif [[ "$1" == "helper" ]] ; then
TO_RUN="/scripts/gcloud-$@"
else
TO_RUN="gcloud $@"
fi
# If we do not have a config container, then we need to auth
if [[ ! `docker ps -a | grep $config_container` ]] ; then
echo -e "\e[1;33m"
echo "No config parameters found. Doing now"
docker run -t -i --name "$config_container" \
-e GCLOUD_PROJECT=$GCLOUD_PROJECT \
-e GCLOUD_ZONE=$GCLOUD_ZONE \
-v /.ssh -v /.config \
-v /root/.ssh -v /root/.config \
-v $dir/scripts:/scripts -v $(pwd):/files \
google/cloud-sdk /scripts/gcloud-helper auth
echo -e "\e[0m"
else
docker run --rm -it --volumes-from "$config_container" \
-v $dir/cloud-config.yaml:/cloud-config.yaml \
-v $dir/scripts:/scripts -v $(pwd):/files \
-v $dir/servers/manifests:/manifests \
-e GCLOUD_PROJECT=$GCLOUD_PROJECT \
-e GCLOUD_ZONE=$GCLOUD_ZONE \
google/cloud-sdk $TO_RUN
fi