From c34a767076e4e9e60b4c2984b1d2a76336d9c8d4 Mon Sep 17 00:00:00 2001 From: LeeW Date: Thu, 13 Feb 2025 16:30:14 +0100 Subject: [PATCH] refactor - move function up with other functions was mixed in between non-function code --- bin/update_sops.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/update_sops.sh b/bin/update_sops.sh index cf91834..9ee53d0 100755 --- a/bin/update_sops.sh +++ b/bin/update_sops.sh @@ -162,6 +162,19 @@ EOM echo " ${fpr_list[${ind_2nd_last}]}" } +fn_sops_updatekeys_and_verify(){ + # call 'sops updatekeys' and dump contents of file so end user can visually verify functionality + sops_enc_file="${1}";shift; + # update keys in secrets file + test -e "${sops_enc_file}" || exit 1 + + # "update the keys of SOPS files using the config file" + sops updatekeys "${sops_enc_file}" + + # verify: dump secrets, GPG_TTY src: https://www.varokas.com/secrets-in-code-with-mozilla-sops/ + GPG_TTY=$(tty) sops -d "${sops_enc_file}" +} + # BEGIN if [[ "${opt_list_roles}" -eq 1 ]]; then # list available roles and exit @@ -186,17 +199,6 @@ pushd "${keyfiles_dir}" > /dev/null 2>&1 popd > /dev/null 2>&1 # VERIFY -fn_sops_updatekeys_and_verify(){ - sops_enc_file="${1}";shift; - # update keys in secrets file - test -e "${sops_enc_file}" || exit 1 - - # "update the keys of SOPS files using the config file" - sops updatekeys "${sops_enc_file}" - - # verify: dump secrets, GPG_TTY src: https://www.varokas.com/secrets-in-code-with-mozilla-sops/ - GPG_TTY=$(tty) sops -d "${sops_enc_file}" -} if [[ "${#secrets_file_list[@]}" != "0" ]]; then for secrets_file in "${secrets_file_list[@]}"; do fn_sops_updatekeys_and_verify "${secrets_file}"