-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopyenv.sh
executable file
·52 lines (46 loc) · 980 Bytes
/
copyenv.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
SERVICE=
DEST=/workspace/.env
REGION=us-central1
PLATFORM=managed
OPTS=$(getopt -o s:d:r:p: --long service:,dest:,region:,platform: -- "$@")
if [ $? != 0 ]; then
echo "Failed parsing options." >&2
exit 1
fi
eval set -- "$OPTS"
while true; do
case "$1" in
-s | --service)
SERVICE=$2
shift 2
;;
-d | --dest)
DEST=$2
shift 2
;;
-r | --region)
REGION=$2
shift 2
;;
-p | --platform)
PLATFORM=$2
shift 2
;;
--)
shift
;;
*)
break
;;
esac
done
if [ -z "$SERVICE" ]; then
echo >&2 "ERROR: -s/--service required"
exit 1
fi
echo "copyenv service=$SERVICE dest=$DEST platform=$PLATFORM region=$REGION"
gcloud run configurations describe $SERVICE \
--format json --platform $PLATFORM --region $REGION |
jq -r '.spec.template.spec.containers[0].env[] | "\(.name)=\(.value)"' \
>$DEST