Compare commits
No commits in common. "b8e666c0750b13871a8a542eee52b92ed8e6de66" and "e413204215415f6cf1b6de2868a76accccaa87ab" have entirely different histories.
b8e666c075
...
e413204215
@ -7,7 +7,6 @@ set -euo pipefail
|
||||
|
||||
SECRETS_FILE="$1"
|
||||
KEY="$2"
|
||||
KEY_SELECTOR="$(jq -Rsc '[.]' <(echo -n "${KEY}"))"
|
||||
|
||||
if [[ -n $EDITOR ]]; then
|
||||
EDITOR=vim
|
||||
@ -15,21 +14,12 @@ fi
|
||||
|
||||
TMP_FILE="$(mktemp)"
|
||||
|
||||
clerie-sops --decrypt --extract "${KEY_SELECTOR}" "${SECRETS_FILE}" > "${TMP_FILE}"
|
||||
|
||||
TMP_FILE_HASH_BEFORE="$(sha256sum "${TMP_FILE}")"
|
||||
clerie-sops --decrypt --extract "[\"${KEY}\"]" "${SECRETS_FILE}" > "${TMP_FILE}"
|
||||
|
||||
vim "${TMP_FILE}"
|
||||
|
||||
TMP_FILE_HASH_AFTER="$(sha256sum "${TMP_FILE}")"
|
||||
|
||||
# Don't write value back when it hasn't changed
|
||||
if [[ "${TMP_FILE_HASH_BEFORE}" == "${TMP_FILE_HASH_AFTER}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
JSON_QUOTED_SECRET="$(jq -Rsc '.' "${TMP_FILE}")"
|
||||
JSON_QUOTED_SECRET="$(jq -Rs '.' "${TMP_FILE}")"
|
||||
|
||||
rm "${TMP_FILE}"
|
||||
|
||||
clerie-sops --set "${KEY_SELECTOR} ${JSON_QUOTED_SECRET}" "${SECRETS_FILE}"
|
||||
clerie-sops --set "[\"${KEY}\"] ${JSON_QUOTED_SECRET}" "${SECRETS_FILE}"
|
||||
|
Loading…
Reference in New Issue
Block a user