-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_pg_make_postico_favorites.sh.tmpl
38 lines (37 loc) · 1.44 KB
/
run_pg_make_postico_favorites.sh.tmpl
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
#!/bin/bash
umask 077
mkdir -p "$HOME/.pg_services"
{{ range $project := list "zeitonline-main" }}
{{- $instances := (print "zon/v1/gcp/" $project "/cloudsql/instances/") }}
{{ range $instance := (secretJSON "kv" "list" "-format=json" $instances) }}
{{ $instance_keys := (secretJSON "kv" "list" "-format=json" (print $instances $instance)) }}
{{ if has "databases/" $instance_keys }}
{{- $databases := (print $instances $instance "/databases/") }}
{{ range $database := (secretJSON "kv" "list" "-format=json" $databases) }}
{{- $inst := (print $instances $instance "instance-credentials" ) }}
{{- $key := (print $databases $database ) }}
( cat <<'PGFAV'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>type</key>
<string>at.eggerapps.PG-Commander.favorite</string>
<key>nickname</key>
<string>{{ (vault $key).data.name }} ({{ (vault $inst).data.environment }})</string>
<key>host</key>
<string>{{ (vault $inst).data.private_dns }}</string>
<key>database</key>
<string>{{ (vault $key).data.name }}</string>
<key>user</key>
<string>{{ (vault $key).data.user }}</string>
<key>password</key>
<string>{{ (vault $key).data.password }}</string>
</dict>
</plist>
PGFAV
) > $HOME/.pg_services/{{ (vault $key).data.name }}-{{ (vault $inst).data.environment }}.pgfav
{{ end }}
{{ end }}
{{ end }}
{{ end }}