update direnv setup

This commit is contained in:
Jason Swank
2026-01-23 18:23:08 +00:00
parent 9d35f280dd
commit a23415c69a
3 changed files with 25 additions and 21 deletions

View File

@@ -0,0 +1,16 @@
# Exports a Podman / Docker secret as an environment variable
export-secret() {
local name="$1"
local file="/run/secrets/${name}"
if [[ ! -f "$file" ]]; then
printf "secret file not found: %s\n" $file >&2
return 1
fi
# Read first line, remove trailing spaces/tabs, convert nulls to newlines
local value
value=$(head -n1 "$file" | sed 's/[ \t]*$//' | tr '\0' '\n')
export "${name}=${value}"
}