[parser] Added --force option

[cmd_export] Now interpretes --force option by ignoring disk usage
This commit is contained in:
ayakael 2018-09-01 11:29:50 -04:00
parent c2c3cc8ab8
commit 4ce3372521
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026
2 changed files with 13 additions and 4 deletions

View file

@ -13,6 +13,7 @@
# }
cmd_export() {
[[ "${1}" == "-f" ]] && { local FORCE="force"; shift; }
local GIT_DIR="${1}"
local TARGET="${2}"
local OLD_COMMIT="${3}"
@ -41,7 +42,11 @@ cmd_export() {
local presentidList=($(awk 'BEGIN{FS="\t"}{if($1=="true" && $4!="null"){print $2}}' ${DB_FILE} | awk '!seen[$0]++'))
local DU="$(( $(print_imageid_du ${GIT_DIR} ${futureidList[@]}) - $(print_imageid_du "${GIT_DIR}" ${presentidList[@]}) ))"
local DF="$(df ${TARGET} --output=avail -B1 | tail -n -1)"
[[ ${DU} -ge ${DF} ]] && { _msg ECHO "Target does not have enough space for deployable IMAGEID. Need ${DU}, has ${DF}."; return 2; }
if [[ ${DU} -ge ${DF} ]] && [[ ${FORCE} != "force" ]]; then
_msg ECHO "Target does not have enough space for deployable IMAGEID. Need ${DU}, has ${DF}."
return 4
fi
# Cleans target of removable TRACKID
local COUNT=1

View file

@ -32,6 +32,10 @@ while true; do
_BATCHID="${1}"
;;
--force|-f)
_FORCE="force"
;;
*)
break
;;
@ -98,21 +102,21 @@ case "${1}" in
--from)
shift
OLD_COMMIT=${1}
shift
;;
*)
TARGET="${1}"
shift
;;
esac
shift
done
cmd_export "${_GIT_DIR}" "${TARGET}" "${OLD_COMMIT}"
cmd_export $([[ ${_FORCE} == "force" ]] && echo '-f') "${_GIT_DIR}" "${TARGET}" ${OLD_COMMIT}
EXIT=$?
[[ ${EXIT} -eq 0 ]] && echo "Deployment completed successfully"
[[ ${EXIT} -eq 1 ]] && echo "Deployment completed with errors"
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
[[ ${EXIT} -eq 4 ]] && echo "Not enough space on device"
;;
update)