s/roles/groups/g , iteration

ADP-216_sops_automation
LeeW 10 months ago
parent e8f1a1acd0
commit 4076e9ee15

@ -121,12 +121,12 @@ function main(){
keyfiles_dir="${repo_root}"
# assume location of secrets config file in pwd
sops_config_dir="${PWD}"
# path to role definitions
roles_def_dir="${repo_root}/roles"
# path to group definitions
groups_def_dir="${repo_root}/groups"
# optional:
opt_list_roles=0
# optional: specify "roles"
roles_list=()
opt_list_groups=0
# optional: specify "groups"
groups_list=()
# optional: secrets files to be updated
secrets_file_list=()
@ -139,10 +139,10 @@ function main(){
-k|--key|--keyfiles) keyfiles_dir="${2}"; shift ;;
# ARGS: dir containing .sops.yaml (sops config file)
-c|--config_dir) sops_config_dir="${2}"; shift ;;
# ARGS: [optional] show list of roles and exit
-lr|--list_roles) opt_list_roles=1 ;;
# ARGS: [optional] [list] specify "roles" which correspond to e.g. job roles, projects, etc
-r|--role) roles_list+=( "${2}" ); shift ;;
# ARGS: [optional] show list of groups and exit
-lg|--list_groups) opt_list_groups=1 ;;
# ARGS: [optional] [list] specify "groups" which correspond to e.g. job groups, projects, etc
-g|--group) groups_list+=( "${2}" ); shift ;;
# ARGS: [optional] [list] specify files containing sops-encrypted secrets
-s|--secrets_file|-f|--file) secrets_file_list+=( "${2}" ); shift ;;
# ARGS: [optional] [list] specify files containing sops-encrypted secrets
@ -153,11 +153,11 @@ function main(){
# Resolve Parameters
# ... i.e. combine,override,etc options which interact
if [[ "${#roles_list[@]}" -eq 1 ]]; then
# simply change keyfiles_dir to the "roles" dir
keyfiles_dir="${roles_def_dir}/${roles_list[0]}"
elif [[ "${#roles_list[@]}" -gt 1 ]]; then
>&2 echo "# ERROR: only specify one role"
if [[ "${#groups_list[@]}" -eq 1 ]]; then
# simply change keyfiles_dir to the "groups" dir
keyfiles_dir="${groups_def_dir}/${groups_list[0]}"
elif [[ "${#groups_list[@]}" -gt 1 ]]; then
>&2 echo "# ERROR: only specify one group"
exit 1
fi
@ -181,10 +181,10 @@ function main(){
# /OPTIONS: ARGPARSING and VALIDATION
# BEGIN
if [[ "${opt_list_roles}" -eq 1 ]]; then
# list available roles and exit
pushd "${roles_def_dir}" > /dev/null 2>&1
>&2 echo "# INFO: listing roles"
if [[ "${opt_list_groups}" -eq 1 ]]; then
# list available groups and exit
pushd "${groups_def_dir}" > /dev/null 2>&1
>&2 echo "# INFO: listing groups"
ls -1d *
exit 0
popd > /dev/null 2>&1

Loading…
Cancel
Save