-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcp-env
executable file
·45 lines (40 loc) · 1.44 KB
/
gcp-env
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
#!/bin/bash -ex
set +x
EXPORT=0
for arg in "$@"
do
case $arg in
-e|--export)
EXPORT=1
shift
;;
-p|--project)
GOOGLE_CLOUD_PROJECT="$2"
shift
;;
esac
done
echo "Listing environment from project $GOOGLE_CLOUD_PROJECT runtime configuration and secret manager"
# Runtime config API has bugs when using --uri so must resort to some pipe cleanup
gcloud beta runtime-config configs list --project=$GOOGLE_CLOUD_PROJECT | tail -n +2 | while read -r config_name ; do
gcloud beta runtime-config configs variables list --config-name=$config_name --project=$GOOGLE_CLOUD_PROJECT | tail -n +2 | while read -r variable ; do
key=`echo $variable | cut -d' ' -f1`
value=`gcloud beta runtime-config configs variables get-value $key --config-name=$config_name --project=$GOOGLE_CLOUD_PROJECT`
echo $key"="$value
if [ $EXPORT -eq 1 ]
then
export $key=$value
fi
done
done
gcloud beta secrets list --project=$GOOGLE_CLOUD_PROJECT --uri | while read -r secret ; do
gcloud beta secrets versions list $secret --project=$GOOGLE_CLOUD_PROJECT --uri | head -n1 | while read -r secret_version ; do
value=`gcloud beta secrets versions access --project=$GOOGLE_CLOUD_PROJECT $secret_version`
key=${secret##*/}
echo $key"="$value
if [ $EXPORT -eq 1 ]
then
export $key=$value
fi
done
done