From 2662a259777b3e5b6768ce38b86fb2fb614f150b Mon Sep 17 00:00:00 2001 From: LeeW Date: Thu, 13 Feb 2025 15:44:57 +0100 Subject: [PATCH] adds function to locate sops config --- bin/update_sops.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/update_sops.sh b/bin/update_sops.sh index b234682..1beaf65 100755 --- a/bin/update_sops.sh +++ b/bin/update_sops.sh @@ -95,21 +95,21 @@ function fn_sops_locate_config_in_git_repo(){ # starting dir, default: PWD. Note: 'realpath' to normalise the dir start_dir="$(realpath "${1:-"${PWD}"}")"; stop_dir="$(git rev-parse --show-toplevel)" + >&2 echo "# ---" + >&2 echo "# start_dir: "${start_dir}"" + >&2 echo "# stop_dir: "${stop_dir}"" - # sops_filepath="" - # being + # BEGIN search_dir="${start_dir}" - # stopping condition - # while [[ "${search_dir}" != "${stop_dir}" ]]; do - contender="${search_dir}/.sops.yaml" - if [[ -e "${contender}" ]]; then - >&2 echo "# BASE CASE" - echo "${contender}" - else - # walk up one dir - >&2 echo "# walk up one dir" - fn_sops_locate_config_in_git_repo "$(dirname "${search_dir}")" - fi + contender="${search_dir}/.sops.yaml" + # base case - located the file OR stopping condition - at top of repo + if [[ -e "${contender}" ]] || [[ "${search_dir}" == "${stop_dir}" ]]; then + >&2 echo "# BASE CASE" + echo "${contender}" + else + >&2 echo "# walk up one dir..." + fn_sops_locate_config_in_git_repo "$(dirname "${search_dir}")" + fi } function fn_sops_generate_config(){