From da29e258e7a57d5f60ff808eb6cd6185854b4fa3 Mon Sep 17 00:00:00 2001 From: LeeW Date: Thu, 13 Feb 2025 16:42:47 +0100 Subject: [PATCH] refactor - consolidate input validation --- bin/update_sops.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/update_sops.sh b/bin/update_sops.sh index a596a7e..1ece238 100755 --- a/bin/update_sops.sh +++ b/bin/update_sops.sh @@ -167,7 +167,11 @@ function main(){ sops_config_dir="$(realpath "${sops_config_dir}")" test -d "${sops_config_dir}" || (echo "E: specify dir containing .sops.yaml, invalid dir: '${sops_config_dir}'" && exit 1) sops_config="${sops_config_dir}/.sops.yaml" - # create it! # test -e "${sops_config}" || (echo "E: could not locate .sops.yaml, tried ${sops_config}" && exit 1) + # locate appropriate sops config if default assumption not found + if [[ ! -e "${sops_config}" ]]; then + # dev note: '2> /dev/null' to disable debug output + sops_config="$(fn_sops_locate_config_in_git_repo 2> /dev/null)" + fi if [[ "${#secrets_file_list[@]}" != "0" ]]; then for secrets_file in "${secrets_file_list[@]}"; do test -e "${secrets_file}" || (echo "E: could not locate file with secrets, tried: ${secrets_file}" && exit 1) @@ -187,11 +191,6 @@ function main(){ fi # UPDATE SOPS CONFIG - # locate sops config - if [[ ! -e "${sops_config}" ]]; then - # dev note: '2> /dev/null' to disable debug output - sops_config="$(fn_sops_locate_config_in_git_repo 2> /dev/null)" - fi # update sops config # TODO: remove the 'pushd;popd' workaround and make the functions aware of the dir being read