fix(tools/_lib): /etc/mosaic host-level fallback for credential resolution #700

Merged
jason.woltje merged 2 commits from fix/credentials-system-fallback into main 2026-07-10 01:57:13 +00:00
Showing only changes of commit c2099114a8 - Show all commits

View File

@@ -88,9 +88,13 @@ get_gitea_service_for_host() {
local host="$1"
local cred_file="${MOSAIC_CREDENTIALS_FILE:-}"
if [[ -z "$cred_file" ]]; then
# Same resolution chain as _lib/credentials.sh: profile HOME, then host-level.
# Same resolution chain as _lib/credentials.sh: profile HOME, then
# host-level /etc only if it exists; neither existing keeps the
# $HOME default (matches the lib's final := fallback).
cred_file="$HOME/.config/mosaic/credentials.json"
[[ -f "$cred_file" ]] || cred_file="/etc/mosaic/credentials.json"
if [[ ! -f "$cred_file" && -f /etc/mosaic/credentials.json ]]; then
cred_file="/etc/mosaic/credentials.json"
fi
fi
case "$host" in