refactor - consolidate input validation

ADP-216_sops_automation
LeeW 10 months ago
parent e2c2f77459
commit da29e258e7

@ -167,7 +167,11 @@ function main(){
sops_config_dir="$(realpath "${sops_config_dir}")" 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) 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" 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 if [[ "${#secrets_file_list[@]}" != "0" ]]; then
for secrets_file in "${secrets_file_list[@]}"; do 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) test -e "${secrets_file}" || (echo "E: could not locate file with secrets, tried: ${secrets_file}" && exit 1)
@ -187,11 +191,6 @@ function main(){
fi fi
# UPDATE SOPS CONFIG # 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 # update sops config
# TODO: remove the 'pushd;popd' workaround and make the functions aware of the dir being read # TODO: remove the 'pushd;popd' workaround and make the functions aware of the dir being read

Loading…
Cancel
Save