adds function to locate sops config

ADP-216_sops_automation
LeeW 10 months ago
parent f4b465a151
commit 2662a25977

@ -95,19 +95,19 @@ function fn_sops_locate_config_in_git_repo(){
# starting dir, default: PWD. Note: 'realpath' to normalise the dir # starting dir, default: PWD. Note: 'realpath' to normalise the dir
start_dir="$(realpath "${1:-"${PWD}"}")"; start_dir="$(realpath "${1:-"${PWD}"}")";
stop_dir="$(git rev-parse --show-toplevel)" stop_dir="$(git rev-parse --show-toplevel)"
>&2 echo "# ---"
>&2 echo "# start_dir: "${start_dir}""
>&2 echo "# stop_dir: "${stop_dir}""
# sops_filepath="" # BEGIN
# being
search_dir="${start_dir}" search_dir="${start_dir}"
# stopping condition
# while [[ "${search_dir}" != "${stop_dir}" ]]; do
contender="${search_dir}/.sops.yaml" contender="${search_dir}/.sops.yaml"
if [[ -e "${contender}" ]]; then # base case - located the file OR stopping condition - at top of repo
if [[ -e "${contender}" ]] || [[ "${search_dir}" == "${stop_dir}" ]]; then
>&2 echo "# BASE CASE" >&2 echo "# BASE CASE"
echo "${contender}" echo "${contender}"
else else
# walk up one dir >&2 echo "# walk up one dir..."
>&2 echo "# walk up one dir"
fn_sops_locate_config_in_git_repo "$(dirname "${search_dir}")" fn_sops_locate_config_in_git_repo "$(dirname "${search_dir}")"
fi fi
} }

Loading…
Cancel
Save