forked from EvergreenCrypto/docker-finance
Merge pull request #108 into master
be6e366client: lib_gen: fix missing copy of custom Dockerfile (Aaron Fiore)b30c00fclient: lib_gen: refactor flow generation (Aaron Fiore)
This commit is contained in:
@@ -393,8 +393,8 @@ function lib_gen::__gen_client()
|
||||
read -p "" _read
|
||||
local _confirm="${_read:-y}"
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
cp -a "$global_custom_dockerfile" "${global_custom_dockerfile}_${global_suffix}" \
|
||||
|| lib_utils::die_fatal
|
||||
cp -a "$global_custom_dockerfile" "${global_custom_dockerfile}_${global_suffix}" || lib_utils::die_fatal
|
||||
cp -fa "$global_repo_custom_dockerfile" "$global_custom_dockerfile" || lib_utils::die_fatal
|
||||
fi
|
||||
else
|
||||
lib_utils::print_custom " \e[32m│\e[0m\n"
|
||||
@@ -417,11 +417,11 @@ function lib_gen::__gen_container()
|
||||
lib_utils::print_debug "Generating container"
|
||||
|
||||
#
|
||||
# Check to proceed with profile-specific
|
||||
# Generate flow
|
||||
#
|
||||
|
||||
lib_utils::print_custom " \e[32m│\e[0m\n"
|
||||
lib_utils::print_custom " \e[32m├─\e[34;1m Generate (or update) container profile configs and/or accounts? [Y/n] \e[0m"
|
||||
lib_utils::print_custom " \e[32m├─\e[34;1m Generate (or update) container flow (profiles, etc.)? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
local _confirm="${_read:-y}"
|
||||
if [[ "$_confirm" != [yY] ]]; then
|
||||
@@ -431,19 +431,27 @@ function lib_gen::__gen_container()
|
||||
fi
|
||||
|
||||
[ -z "$DOCKER_FINANCE_CLIENT_FLOW" ] && lib_utils::die_fatal
|
||||
if [ -d "$DOCKER_FINANCE_CLIENT_FLOW" ]; then
|
||||
lib_utils::print_custom " \e[32m│ ├─\e[34m hledger-flow path exists, continue with backup and generation? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
if [[ "$_confirm" != [yY] ]]; then
|
||||
lib_utils::print_custom " \e[32m│\e[0m\n"
|
||||
lib_utils::print_normal ""
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -d "$DOCKER_FINANCE_CLIENT_FLOW" ]; then
|
||||
mkdir -p "$DOCKER_FINANCE_CLIENT_FLOW" || lib_utils::die_fatal
|
||||
fi
|
||||
|
||||
#
|
||||
# Development setup
|
||||
# Generate profile/subprofile
|
||||
#
|
||||
|
||||
lib_gen::__gen_profile
|
||||
}
|
||||
|
||||
function lib_gen::__gen_profile()
|
||||
{
|
||||
local -r _profiles="${DOCKER_FINANCE_CLIENT_FLOW}/profiles"
|
||||
if [ ! -d "$_profiles" ]; then
|
||||
mkdir -p "$_profiles" || lib_utils::die_fatal
|
||||
fi
|
||||
|
||||
#
|
||||
# Profile: development setup
|
||||
#
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │\e[0m\n"
|
||||
@@ -456,7 +464,7 @@ function lib_gen::__gen_container()
|
||||
lib_utils::print_debug "_is_testing=${_is_testing}"
|
||||
|
||||
#
|
||||
# Construct full path to subprofile
|
||||
# Profile: construct full path to subprofile
|
||||
#
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │ │\e[0m\n"
|
||||
@@ -471,8 +479,20 @@ function lib_gen::__gen_container()
|
||||
local -r _subprofile="${_read:-${global_user}}"
|
||||
lib_utils::print_custom " \e[32m│ │ └─\e[34m Using subprofile:\e[0m ${_subprofile}\n"
|
||||
|
||||
if [ -d "${_profiles}/${_profile}/${_subprofile}" ]; then
|
||||
lib_utils::print_custom " \e[32m│ │ └─\e[34m Subprofile exists! Continue with backup and generation? [Y/n] \e[0m"
|
||||
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
if [[ "$_confirm" != [yY] ]]; then
|
||||
lib_utils::print_custom " \e[32m│\e[0m\n"
|
||||
lib_utils::print_normal ""
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Execute profile-specific
|
||||
# Profile: execute profile-specific
|
||||
#
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │\e[0m\n"
|
||||
@@ -485,7 +505,7 @@ function lib_gen::__gen_container()
|
||||
lib_utils::print_debug "_gen_path=${_gen_path}"
|
||||
lib_utils::print_debug "_gen_conf_path=${_gen_conf_path}"
|
||||
|
||||
lib_gen::__gen_shell "$_gen_path" "$_gen_conf_path"
|
||||
lib_gen::__gen_subprofile_shell "$_gen_path" "$_gen_conf_path"
|
||||
fi
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │\e[0m\n"
|
||||
@@ -493,33 +513,34 @@ function lib_gen::__gen_container()
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
local _gen_path="${DOCKER_FINANCE_CLIENT_FLOW}/profiles/${_profile}/${_subprofile}" # client's view
|
||||
local _gen_path="${_profiles}/${_profile}/${_subprofile}" # client's view
|
||||
local _gen_conf_path="${_gen_path}/docker-finance.d"
|
||||
lib_utils::print_debug "_gen_path=${_gen_path}"
|
||||
lib_utils::print_debug "_gen_conf_path=${_gen_conf_path}"
|
||||
|
||||
lib_gen::__gen_hledger "$_gen_path" "$_gen_conf_path"
|
||||
lib_gen::__gen_subprofile_hledger "$_gen_path" "$_gen_conf_path"
|
||||
fi
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │\e[0m\n"
|
||||
lib_utils::print_custom " \e[32m│ ├─\e[34;1m Generate (or update) container hledger-flow configs and/or accounts? [Y/n] \e[0m"
|
||||
lib_utils::print_custom " \e[32m│ ├─\e[34;1m Generate (or update) container flow configs and/or accounts? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
local _gen_path="${DOCKER_FINANCE_CLIENT_FLOW}/profiles/${_profile}/${_subprofile}"
|
||||
local _gen_path="${_profiles}/${_profile}/${_subprofile}"
|
||||
local _gen_conf_path="${_gen_path}/docker-finance.d"
|
||||
lib_utils::print_debug "_gen_path=${_gen_path}"
|
||||
lib_utils::print_debug "_gen_conf_path=${_gen_conf_path}"
|
||||
|
||||
lib_gen::__gen_flow "$_gen_path" "$_gen_conf_path"
|
||||
lib_gen::__gen_subprofile_flow "$_gen_path" "$_gen_conf_path"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Generate client-side container superscript
|
||||
# Subprofile: generate client-side container superscript
|
||||
# TODO: separate superscript gen from subprofile append
|
||||
#
|
||||
|
||||
function lib_gen::__gen_shell()
|
||||
function lib_gen::__gen_subprofile_shell()
|
||||
{
|
||||
local -r _gen_path="$1"
|
||||
local -r _gen_conf_path="$2"
|
||||
@@ -546,12 +567,12 @@ function lib_gen::__gen_shell()
|
||||
lib_utils::print_debug "${_backup[@]}"
|
||||
"${_backup[@]}" || lib_utils::die_fatal
|
||||
# Write
|
||||
lib_gen::__gen_shell_write
|
||||
lib_gen::__gen_subprofile_shell_write
|
||||
fi
|
||||
local _print_custom=" \e[32m│ │ └─\e[34m Edit (new) superscript now? [Y/n] \e[0m"
|
||||
else
|
||||
# Generate new default file
|
||||
lib_gen::__gen_shell_write
|
||||
lib_gen::__gen_subprofile_shell_write
|
||||
local _print_custom=" \e[32m│ │ └─\e[34m Edit (new) superscript now? [Y/n] \e[0m"
|
||||
fi
|
||||
lib_utils::print_custom "$_print_custom"
|
||||
@@ -560,7 +581,7 @@ function lib_gen::__gen_shell()
|
||||
[[ "$_confirm" == [yY] ]] && $EDITOR "$_file"
|
||||
}
|
||||
|
||||
function lib_gen::__gen_shell_write()
|
||||
function lib_gen::__gen_subprofile_shell_write()
|
||||
{
|
||||
[ -z "$global_repo_conf_dir" ] && lib_utils::die_fatal
|
||||
lib_utils::print_debug "global_repo_conf_dir=${global_repo_conf_dir}"
|
||||
@@ -575,10 +596,10 @@ function lib_gen::__gen_shell_write()
|
||||
}
|
||||
|
||||
#
|
||||
# Generate hledger configuration file
|
||||
# Subprofile: generate hledger configuration file
|
||||
#
|
||||
|
||||
function lib_gen::__gen_hledger()
|
||||
function lib_gen::__gen_subprofile_hledger()
|
||||
{
|
||||
local -r _gen_path="$1"
|
||||
local -r _gen_conf_path="$2"
|
||||
@@ -595,11 +616,11 @@ function lib_gen::__gen_hledger()
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
cp -a "$_file" "${_file}_${global_suffix}" || lib_utils::die_fatal
|
||||
|
||||
lib_gen::__gen_hledger_write "$_file"
|
||||
lib_gen::__gen_subprofile_hledger_write "$_file"
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) hledger configuration now? [Y/n] \e[0m"
|
||||
fi
|
||||
else
|
||||
lib_gen::__gen_hledger_write "$_file"
|
||||
lib_gen::__gen_subprofile_hledger_write "$_file"
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) hledger configuration now? [Y/n] \e[0m"
|
||||
fi
|
||||
|
||||
@@ -609,7 +630,7 @@ function lib_gen::__gen_hledger()
|
||||
[[ "$_confirm" == [yY] ]] && $EDITOR "$_file"
|
||||
}
|
||||
|
||||
function lib_gen::__gen_hledger_write()
|
||||
function lib_gen::__gen_subprofile_hledger_write()
|
||||
{
|
||||
local _file="$1"
|
||||
[ -z "$_file" ] && lib_utils::die_fatal
|
||||
@@ -626,10 +647,10 @@ function lib_gen::__gen_hledger_write()
|
||||
}
|
||||
|
||||
#
|
||||
# Generate hledger-flow
|
||||
# Subprofile: generate flow
|
||||
#
|
||||
|
||||
function lib_gen::__gen_flow()
|
||||
function lib_gen::__gen_subprofile_flow()
|
||||
{
|
||||
local -r _gen_path="$1"
|
||||
local -r _gen_conf_path="$2"
|
||||
@@ -638,25 +659,25 @@ function lib_gen::__gen_flow()
|
||||
lib_utils::print_custom " \e[32m│ │ ├─\e[34;1m Generate (or update) subprofile's shell script? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_flow_shell
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_subprofile_flow_shell
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │ │\e[0m\n"
|
||||
lib_utils::print_custom " \e[32m│ │ ├─\e[34;1m Generate (or update) subprofile's fetch configuration? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_flow_fetch
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_subprofile_flow_fetch
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │ │\e[0m\n"
|
||||
lib_utils::print_custom " \e[32m│ │ ├─\e[34;1m Generate (or update) subprofile's financial metadata? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_flow_meta
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_subprofile_flow_meta
|
||||
|
||||
lib_utils::print_custom " \e[32m│ │ │\e[0m\n"
|
||||
lib_utils::print_custom " \e[32m│ │ ├─\e[34;1m Generate (or update) subprofile's hledger-flow accounts? [Y/n] \e[0m"
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_flow_accounts
|
||||
[[ "$_confirm" == [yY] ]] && lib_gen::__gen_subprofile_flow_accounts
|
||||
|
||||
lib_utils::print_custom " \e[32m│\e[0m\n"
|
||||
|
||||
@@ -671,10 +692,10 @@ function lib_gen::__gen_flow()
|
||||
}
|
||||
|
||||
#
|
||||
# Generate subprofile script
|
||||
# Subprofile: flow: generate subprofile script
|
||||
#
|
||||
|
||||
function lib_gen::__gen_flow_shell()
|
||||
function lib_gen::__gen_subprofile_flow_shell()
|
||||
{
|
||||
local _dir="${_gen_conf_path}/shell"
|
||||
[ ! -d "$_dir" ] && mkdir -p "$_dir"
|
||||
@@ -688,11 +709,11 @@ function lib_gen::__gen_flow_shell()
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
cp -a "$_file" "${_file}_${global_suffix}" || lib_utils::die_fatal
|
||||
|
||||
lib_gen::__gen_flow_shell_write
|
||||
lib_gen::__gen_subprofile_flow_shell_write
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile script now? [Y/n] \e[0m"
|
||||
fi
|
||||
else
|
||||
lib_gen::__gen_flow_shell_write
|
||||
lib_gen::__gen_subprofile_flow_shell_write
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile script now? [Y/n] \e[0m"
|
||||
fi
|
||||
|
||||
@@ -702,7 +723,7 @@ function lib_gen::__gen_flow_shell()
|
||||
[[ "$_confirm" == [yY] ]] && $EDITOR "$_file"
|
||||
}
|
||||
|
||||
function lib_gen::__gen_flow_shell_write()
|
||||
function lib_gen::__gen_subprofile_flow_shell_write()
|
||||
{
|
||||
[ -z "$DOCKER_FINANCE_CONTAINER_CMD" ] && lib_utils::die_fatal
|
||||
sed \
|
||||
@@ -715,10 +736,10 @@ function lib_gen::__gen_flow_shell_write()
|
||||
}
|
||||
|
||||
#
|
||||
# Generate client-side container fetch
|
||||
# Subprofile: flow: generate fetch config
|
||||
#
|
||||
|
||||
function lib_gen::__gen_flow_fetch()
|
||||
function lib_gen::__gen_subprofile_flow_fetch()
|
||||
{
|
||||
local _dir="${_gen_conf_path}/fetch"
|
||||
[ ! -d "$_dir" ] && mkdir -p "$_dir"
|
||||
@@ -733,11 +754,11 @@ function lib_gen::__gen_flow_fetch()
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
cp -a "$_file" "${_file}_${global_suffix}" || lib_utils::die_fatal
|
||||
|
||||
lib_gen::__gen_flow_fetch_write
|
||||
lib_gen::__gen_subprofile_flow_fetch_write
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile's fetch configuration now? [Y/n] \e[0m"
|
||||
fi
|
||||
else
|
||||
lib_gen::__gen_flow_fetch_write
|
||||
lib_gen::__gen_subprofile_flow_fetch_write
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile's fetch configuration now? [Y/n] \e[0m"
|
||||
fi
|
||||
|
||||
@@ -747,7 +768,7 @@ function lib_gen::__gen_flow_fetch()
|
||||
[[ "$_confirm" == [yY] ]] && $EDITOR "$_file"
|
||||
}
|
||||
|
||||
function lib_gen::__gen_flow_fetch_write()
|
||||
function lib_gen::__gen_subprofile_flow_fetch_write()
|
||||
{
|
||||
[ -z "$_profile" ] && lib_utils::die_fatal
|
||||
[ -z "$_subprofile" ] && lib_utils::die_fatal
|
||||
@@ -765,10 +786,10 @@ function lib_gen::__gen_flow_fetch_write()
|
||||
}
|
||||
|
||||
#
|
||||
# Generate financial metadata
|
||||
# Subprofile: flow: generate financial metadata
|
||||
#
|
||||
|
||||
function lib_gen::__gen_flow_meta()
|
||||
function lib_gen::__gen_subprofile_flow_meta()
|
||||
{
|
||||
local _dir="${_gen_conf_path}/meta"
|
||||
[ ! -d "$_dir" ] && mkdir -p "$_dir"
|
||||
@@ -783,11 +804,11 @@ function lib_gen::__gen_flow_meta()
|
||||
if [[ "$_confirm" == [yY] ]]; then
|
||||
cp -a "$_file" "${_file}_${global_suffix}" || lib_utils::die_fatal
|
||||
|
||||
lib_gen::__gen_flow_meta_write
|
||||
lib_gen::__gen_subprofile_flow_meta_write
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile's financial metadata now? [Y/n] \e[0m"
|
||||
fi
|
||||
else
|
||||
lib_gen::__gen_flow_meta_write
|
||||
lib_gen::__gen_subprofile_flow_meta_write
|
||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile's financial metadata now? [Y/n] \e[0m"
|
||||
fi
|
||||
|
||||
@@ -797,7 +818,7 @@ function lib_gen::__gen_flow_meta()
|
||||
[[ "$_confirm" == [yY] ]] && $EDITOR "$_file"
|
||||
}
|
||||
|
||||
function lib_gen::__gen_flow_meta_write()
|
||||
function lib_gen::__gen_subprofile_flow_meta_write()
|
||||
{
|
||||
# Deletes default comments or else ROOT meta sample won't work out-of-the-box
|
||||
sed \
|
||||
@@ -807,10 +828,10 @@ function lib_gen::__gen_flow_meta_write()
|
||||
}
|
||||
|
||||
#
|
||||
# Generate accounts
|
||||
# Subprofile: flow: generate accounts
|
||||
#
|
||||
|
||||
function lib_gen::__gen_flow_accounts()
|
||||
function lib_gen::__gen_subprofile_flow_accounts()
|
||||
{
|
||||
lib_utils::print_debug "Generating accounts"
|
||||
|
||||
@@ -846,17 +867,17 @@ function lib_gen::__gen_flow_accounts()
|
||||
read -p "" _read
|
||||
_confirm="${_read:-y}"
|
||||
[[ "$_confirm" == [yY] ]] \
|
||||
&& lib_gen::__gen_flow_accounts_populate "$_subprofile_path" "$_template_path" "$_is_testing"
|
||||
&& lib_gen::__gen_subprofile_flow_accounts_populate "$_subprofile_path" "$_template_path" "$_is_testing"
|
||||
done
|
||||
else
|
||||
for _template_path in "${_templates_paths[@]}"; do
|
||||
lib_utils::print_debug "$_subprofile_path $_template_path $_is_testing"
|
||||
lib_gen::__gen_flow_accounts_populate "$_subprofile_path" "$_template_path" "$_is_testing"
|
||||
lib_gen::__gen_subprofile_flow_accounts_populate "$_subprofile_path" "$_template_path" "$_is_testing"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function lib_gen::__gen_flow_accounts_populate()
|
||||
function lib_gen::__gen_subprofile_flow_accounts_populate()
|
||||
{
|
||||
[ -z "$1" ] && lib_utils::die_fatal
|
||||
[ -z "$2" ] && lib_utils::die_fatal
|
||||
|
||||
Reference in New Issue
Block a user