Files
holos/hack/tilt/get-pgadmin-creds
Jeff McCune d6ee1864c8 (#116) Tilt for development
Add Tilt back from holos server

Note with this patch the ec-creds.yaml file needs to be applied to the
provisioner and an external secret used to sync the image pull creds.

With this patch the dev instance is accessible behind the auth proxy.
pgAdmin also works from the Tilt UI.

https://jeff.holos.dev.k2.ois.run/app/start
2024-04-09 20:26:37 -07:00

38 lines
949 B
Bash
Executable File

#! /bin/bash
#
tmpdir="$(mktemp -d)"
finish() {
code=$?
if [[ $code -gt 10 ]]; then
jq . "${tmpdir}/creds.json"
echo "could not update pg password: jq got null on line $code" >&2
fi
rm -rf "$tmpdir"
exit $code
}
trap finish EXIT
set -euo pipefail
umask 077
if [[ $(uname) != Darwin ]]; then
pbcopy() {
xsel --input --clipboard
xsel --output --clipboard | xsel --input --primary
}
fi
sel="postgres-operator.crunchydata.com/pgadmin=${1}"
# secret="(kubectl -n "${NAMESPACE}" get secret --selector=$sel '--output=jsonpath={.items..metadata.name}')"
kubectl get secret "--selector=$sel" -o=json | jq '.items[].data | map_values(@base64d)' > "${tmpdir}/creds.json"
echo -n "username: "
jq --exit-status -r ".username" "${tmpdir}/creds.json"
password="$(jq --exit-status -r ".password" "${tmpdir}/creds.json")"
# n.b. don't send the trailing newline.
echo -n "$password" | pbcopy
echo "password: copied to clipboard."