pkgs/clerie-sops: Add clerie-sops-edit for working with multiline string attributes in json
This commit is contained in:
25
pkgs/clerie-sops/clerie-sops-edit.sh
Executable file
25
pkgs/clerie-sops/clerie-sops-edit.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Edit a single attribute of a sops json file
|
||||
# Helps working with multiline strings in json
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SECRETS_FILE="$1"
|
||||
KEY="$2"
|
||||
|
||||
if [[ -n $EDITOR ]]; then
|
||||
EDITOR=vim
|
||||
fi
|
||||
|
||||
TMP_FILE="$(mktemp)"
|
||||
|
||||
clerie-sops --decrypt --extract "[\"${KEY}\"]" "${SECRETS_FILE}" > "${TMP_FILE}"
|
||||
|
||||
vim "${TMP_FILE}"
|
||||
|
||||
JSON_QUOTED_SECRET="$(jq -Rs '.' "${TMP_FILE}")"
|
||||
|
||||
rm "${TMP_FILE}"
|
||||
|
||||
clerie-sops --set "[\"${KEY}\"] ${JSON_QUOTED_SECRET}" "${SECRETS_FILE}"
|
Reference in New Issue
Block a user