1
0

pkgs/clerie-sops: Do not write back unchanged values in clerie-sops-edit

This commit is contained in:
clerie 2024-05-02 12:28:22 +02:00
parent e413204215
commit 730903d0d8

View File

@ -16,8 +16,17 @@ TMP_FILE="$(mktemp)"
clerie-sops --decrypt --extract "[\"${KEY}\"]" "${SECRETS_FILE}" > "${TMP_FILE}"
TMP_FILE_HASH_BEFORE="$(sha256sum "${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 -Rs '.' "${TMP_FILE}")"
rm "${TMP_FILE}"