railiance-apps/tools/forgejo-helm-secrets.sh
tegwick 0da83472c4
All checks were successful
CI Smoke / host-smoke (push) Successful in 1s
CI Smoke / container-smoke (push) Successful in 5s
Default railiance01 kubeconfig to config-railiance01
config-hosteurope names port 16443, but the k3s-api-railiance01
ops-bridge tunnel listens on 16444, so every default target failed
with connection refused. Switch Makefile, tools and docs to
~/.kube/config-railiance01 and fix the restore recipe to rewrite the
API address to the tunnel port. The node-side hostPath in STATE.md is
unrelated and unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 1031639@bnt-lap001
Assistant-Session: e5073fee-f4ae-4fc3-a75a-6c1fc83e0576
2026-10-17 11:46:40 +02:00

42 lines
No EOL
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Emit Helm values for Forgejo DB + admin secrets (no mailer — OpenBao/ESO owns SMTP).
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SECRETS_FILE="${FORGEJO_SECRETS:-$ROOT_DIR/helm/forgejo-secrets.sops.yaml}"
KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config-railiance01}"
emit_from_sops() {
sops -d "$SECRETS_FILE" | python3 -c "
import sys, yaml
data = yaml.safe_load(sys.stdin) or {}
mailer = data.get('gitea', {}).get('config', {}).get('mailer')
if mailer:
data['gitea']['config'].pop('mailer', None)
yaml.dump(data, sys.stdout, default_flow_style=False)
"
}
emit_from_cluster() {
python3 -c "
import json, os, subprocess, sys, yaml
os.environ['KUBECONFIG'] = '${KUBECONFIG}'
vals = json.loads(subprocess.check_output(
['helm', 'get', 'values', 'forgejo', '-n', 'forgejo', '-o', 'json'], text=True))
g = vals.get('gitea', {})
yaml.dump({
'gitea': {
'admin': {'password': g.get('admin', {}).get('password', '')},
'config': {
'database': {'PASSWD': g.get('config', {}).get('database', {}).get('PASSWD', '')},
},
}
}, sys.stdout, default_flow_style=False)
"
}
if command -v sops >/dev/null 2>&1 && sops -d "$SECRETS_FILE" >/dev/null 2>&1; then
emit_from_sops
else
emit_from_cluster
fi