Last active
December 31, 2018 19:48
-
-
Save jessedearing/df563df7c273d5da095cc0431e10322a 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
#!/usr/bin/env bash | |
set -e | |
# Eval so we can set the JSON values as shell variables | |
eval "$(jq -r '@sh "VAULT=\(.vault) UUID=\(.uuid)"')" | |
# Get the token or password from the first field of the second section (this is just how I store them, but you could use jq's select | |
password=`op get item --vault=$VAULT $UUID | jq -r '.details.sections[1].fields[0].v'` | |
if [ -z "$password" ]; then | |
# I didn't get a token, so let's bail | |
echo "No token returned. Did you run 'op signin company-one-pass'?" | |
exit 1 | |
fi | |
# Use JQ to put args into a JSON string we return to STDOUT | |
jq -n --arg token "$password" '{"password":$password}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment