From cd2634e845f740a2f9f173019f2bf8e707747138 Mon Sep 17 00:00:00 2001 From: LeeW Date: Mon, 3 Feb 2025 10:49:20 +0100 Subject: [PATCH] refactor: args, secrets files --- bin/update_sops.sh | 1 + example/cmd_sops.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/update_sops.sh b/bin/update_sops.sh index 0c2804e..b1a2a06 100755 --- a/bin/update_sops.sh +++ b/bin/update_sops.sh @@ -15,6 +15,7 @@ while (( $# >= 1 ));do case $cur in -k|--key|--keyfiles) keyfiles_dir="${2}"; shift ;; -c|--config_dir) sops_config_dir="${2}"; shift ;; + -s|--secrets_file|-f|--file) secrets_file_list+=( "${2}" ); shift ;; *) secrets_file_list+=( "${cur}" ) esac shift; diff --git a/example/cmd_sops.sh b/example/cmd_sops.sh index 0085e34..f597e5f 100755 --- a/example/cmd_sops.sh +++ b/example/cmd_sops.sh @@ -10,6 +10,10 @@ secrets_file="mock_secrets.yaml" test -e "${secrets_file}" || (yq -n '.demo.credentials.secret = "hunter2"' > "${secrets_file}" && sops -e -i "${secrets_file}" ) set -x -# ../bin/update_sops.sh -k "${keys_dir}" -c "${sops_cfg_dir}" "${secrets_file}" +# SAMPLE COMMANDS - manually uncomment to try out +# minimal operation: update .sops.yaml, update keys in encrypted file ../bin/update_sops.sh "${secrets_file}" -# test: uncomment, expect: error # ../bin/update_sops.sh "${secrets_file}" secrets.yaml +# Full Args: specify path to each, also for secrets, mix specified and positional params +# ../bin/update_sops.sh -k "${keys_dir}" -c "${sops_cfg_dir}" -s "${secrets_file}" "${secrets_file}" +# TEST: induce error: invalid file +# ../bin/update_sops.sh "${secrets_file}" -s non_existing_secrets.yaml