refactor: args

ADP-179_sops_manage_keys
LeeW 11 months ago
parent cd2634e845
commit 233173e9ac

@ -2,7 +2,7 @@
# Purpose: manage .sops.yaml based on gpg keys in the same dir _and_ verify correct configuration # Purpose: manage .sops.yaml based on gpg keys in the same dir _and_ verify correct configuration
set -euo pipefail set -euo pipefail
# OPTIONS AND ARGPARSING # OPTIONS: ARGPARSING and VALIDATION
# assume location of script as running directly from repo with keys (instead of as a standalone packaged tool) # assume location of script as running directly from repo with keys (instead of as a standalone packaged tool)
keyfiles_dir="$(realpath $(dirname "${BASH_SOURCE[0]}")/..)" keyfiles_dir="$(realpath $(dirname "${BASH_SOURCE[0]}")/..)"
# assume location of secrets config file in pwd # assume location of secrets config file in pwd
@ -21,6 +21,7 @@ while (( $# >= 1 ));do
shift; shift;
done done
# VALIDATE INPUTS
keyfiles_dir="$(realpath "${keyfiles_dir}")" keyfiles_dir="$(realpath "${keyfiles_dir}")"
test -d "${keyfiles_dir}" || (echo "E: specify dir containing keyfiles; invalid dir: '${keyfiles_dir}'" && exit 1) test -d "${keyfiles_dir}" || (echo "E: specify dir containing keyfiles; invalid dir: '${keyfiles_dir}'" && exit 1)
sops_config_dir="$(realpath "${sops_config_dir}")" sops_config_dir="$(realpath "${sops_config_dir}")"
@ -32,7 +33,8 @@ if [[ "${#secrets_file_list[@]}" != "0" ]]; then
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)
done done
fi fi
# /OPTIONS AND ARGPARSING # /VALIDATE INPUTS
# /OPTIONS: ARGPARSING and VALIDATION
function fn_extract_fpr(){ function fn_extract_fpr(){
gpgkeyfile=$1;shift; gpgkeyfile=$1;shift;

Loading…
Cancel
Save