2024-05-03 19:40:44 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# @file Fig Login
|
|
|
|
# @brief Logs into Fig using the FIG_TOKEN
|
|
|
|
|
2024-05-27 20:45:14 -07:00
|
|
|
set -Eeuo pipefail
|
2024-05-27 20:50:11 -07:00
|
|
|
trap "gum log -sl error 'Script encountered an error!'" ERR
|
2024-05-27 04:15:03 -07:00
|
|
|
|
2024-05-03 19:40:44 -07:00
|
|
|
if command -v fig > /dev/null; then
|
2024-05-27 04:15:03 -07:00
|
|
|
### Ensure FIG_TOKEN
|
2024-05-27 20:45:14 -07:00
|
|
|
if get-secret --exists FIG_TOKEN; then
|
|
|
|
### Login to Fig
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info "Logging into Fig with FIG_TOKEN"
|
|
|
|
fig login --token "$(get-secret FIG_TOKEN)" || gum log -sl info 'Fig login failed - User might already be logged in'
|
2024-05-27 20:45:14 -07:00
|
|
|
fi
|
2024-05-03 19:40:44 -07:00
|
|
|
else
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl warn 'fig is not available in the PATH'
|
2024-05-03 19:40:44 -07:00
|
|
|
fi
|