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(){