Skip to content

Instantly share code, notes, and snippets.

@ByronScottJones
Last active March 8, 2022 20:12
Show Gist options
  • Save ByronScottJones/52aeeefbec275b1613b3497d42aba32f to your computer and use it in GitHub Desktop.
Save ByronScottJones/52aeeefbec275b1613b3497d42aba32f to your computer and use it in GitHub Desktop.
alias getsecret="_getsecret"
# ~/.secrets/secrets.json !!! chmod 400
# {
# "group1": {
# "secret1":"value",
# "secret2":"value"
# },
# "group2": {
# "secret1":"value",
# "secret2":"value"
# }
# }
#Using with user variables:
# VARIABLE_NAME=$(getsecret group secret)
function _getsecret() {
SECRETS_PATH=${HOME}/.secrets/secrets.json
case ${#} in
0)
listsecrets
;;
1)
cat $SECRETS_PATH | jq -r ".[\"$1\"]"
;;
2)
cat $SECRETS_PATH | jq -r ".[\"$1\"] | .[\"$2\"] "
;;
3)
echo "ex: getsecret group secret"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment