-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.envrc
More file actions
26 lines (23 loc) · 1.16 KB
/
Copy path.envrc
File metadata and controls
26 lines (23 loc) · 1.16 KB
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
# Load environment variables from .env if it exists
if [ -f .env ]; then
dotenv .env
fi
# Tab completion for 'task tg -- <cmd> <dir>' (bash only)
if [ -n "$BASH_VERSION" ] && type complete &>/dev/null; then
_task_tg_completion() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local dirs=$(find terraform -mindepth 1 -type d ! -path '*/.terragrunt*' ! -path '*/.terraform*' 2>/dev/null | sed 's|^terraform/||')
COMPREPLY=($(compgen -W "$dirs" -- "$cur"))
}
complete -F _task_tg_completion -o default task
fi
# Load devbox environment
eval "$(devbox generate direnv --print-envrc)"
# Decrypt talos configs if sops key is available
if [ -f ~/.config/sops/age/keys.txt ]; then
SECRETS_DIR="${XDG_RUNTIME_DIR:-$HOME/.cache}/homelab-secrets"
mkdir -p "$SECRETS_DIR" && chmod 700 "$SECRETS_DIR"
# Extract 'data' field after decryption (SOPS wraps content in data key)
sops -d --output-type json talos/kubeconfig 2>/dev/null | jq -r '.data' > "$SECRETS_DIR/kubeconfig" && export KUBECONFIG="$SECRETS_DIR/kubeconfig"
sops -d --output-type json talos/talosconfig 2>/dev/null | jq -r '.data' > "$SECRETS_DIR/talosconfig" && export TALOSCONFIG="$SECRETS_DIR/talosconfig"
fi