Last active
March 8, 2022 20:12
-
-
Save ByronScottJones/52aeeefbec275b1613b3497d42aba32f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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