dk: ajout de l'option --fake pour afficher les commandes

This commit is contained in:
Jephté Clain 2018-11-19 09:56:04 +04:00
parent dcb637e054
commit 45da726704
1 changed files with 25 additions and 14 deletions

39
dk
View File

@ -11,7 +11,8 @@ USAGE
COMMANDES COMMANDES
build build
push push
run start, run
stop
up up
logs logs
down down
@ -19,7 +20,15 @@ COMMANDES
ps ps
ls ls
rm rm
prune" prune
OPTIONS
-d, --chdir PROJDIR
-p, --profile PROFILE
-P, --prod
-T, --test
-j, --no-cache
-n, --fake"
} }
function get_version() { function get_version() {
@ -109,7 +118,7 @@ function default_update_build_env() {
function update_build_env() { default_update_build_env; } function update_build_env() { default_update_build_env; }
function default_compose_build() { function default_compose_build() {
docker-compose \ ${FAKE:+qvals} docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
build \ build \
${NO_CACHE:+--no-cache} \ ${NO_CACHE:+--no-cache} \
@ -121,7 +130,7 @@ function default_docker_build() {
for tag in "${TAGS[@]}"; do for tag in "${TAGS[@]}"; do
replace_build_args+=(-t "$NAME:$tag") replace_build_args+=(-t "$NAME:$tag")
done done
docker build \ ${FAKE:+qvals} docker build \
${NO_CACHE:+--no-cache} \ ${NO_CACHE:+--no-cache} \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
"${replace_build_args[@]}" "${build_args[@]}" \ "${replace_build_args[@]}" "${build_args[@]}" \
@ -160,18 +169,18 @@ function auto_push() {
update_build_env update_build_env
fi fi
for tag in "${TAGS[@]}"; do for tag in "${TAGS[@]}"; do
docker push "$NAME:$tag" ${FAKE:+qvals} docker push "$NAME:$tag"
done done
} }
function default_compose_up() { function default_compose_up() {
docker-compose \ ${FAKE:+qvals} docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
up "${replace_run_args[@]}" "${run_args[@]}" \ up "${replace_run_args[@]}" "${run_args[@]}" \
"${replace_user_args[@]}" "${user_args[@]}" "$@" "${replace_user_args[@]}" "${user_args[@]}" "$@"
} }
function default_docker_up() { function default_docker_up() {
docker run \ ${FAKE:+qvals} docker run \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
"${replace_run_args[@]}" "${run_args[@]}" \ "${replace_run_args[@]}" "${run_args[@]}" \
"$NAME" \ "$NAME" \
@ -196,13 +205,13 @@ function auto_up() {
} }
function default_compose_stop() { function default_compose_stop() {
docker-compose \ ${FAKE:+qvals} docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
stop "${replace_stop_args[@]}" "${stop_args[@]}" \ stop "${replace_stop_args[@]}" "${stop_args[@]}" \
"$@" "$@"
} }
function default_docker_stop() { function default_docker_stop() {
docker container stop \ ${FAKE:+qvals} docker container stop \
"${replace_stop_args[@]}" "${stop_args[@]}" \ "${replace_stop_args[@]}" "${stop_args[@]}" \
"$name" "$@" "$name" "$@"
} }
@ -222,13 +231,13 @@ function auto_stop() {
} }
function default_compose_logs() { function default_compose_logs() {
docker-compose \ ${FAKE:+qvals} docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
logs "${replace_logs_args[@]}" "${logs_args[@]}" \ logs "${replace_logs_args[@]}" "${logs_args[@]}" \
"$@" "$@"
} }
function default_docker_logs() { function default_docker_logs() {
docker logs \ ${FAKE:+qvals} docker logs \
"${replace_logs_args[@]}" "${logs_args[@]}" \ "${replace_logs_args[@]}" "${logs_args[@]}" \
"$name" "$@" "$name" "$@"
} }
@ -250,18 +259,18 @@ function auto_logs() {
} }
function default_compose_down() { function default_compose_down() {
docker-compose \ ${FAKE:+qvals} docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
down "${replace_down_args[@]}" "${down_args[@]}" \ down "${replace_down_args[@]}" "${down_args[@]}" \
"$@" "$@"
} }
function default_docker_down() { function default_docker_down() {
estep "stop" estep "stop"
docker container stop \ ${FAKE:+qvals} docker container stop \
"${replace_down_args[@]}" "${down_args[@]}" \ "${replace_down_args[@]}" "${down_args[@]}" \
"$name" "$@" "$name" "$@"
estep "rm" estep "rm"
docker container rm \ ${FAKE:+qvals} docker container rm \
"${replace_rm_args[@]}" "${rm_args[@]}" \ "${replace_rm_args[@]}" "${rm_args[@]}" \
"$name" "$name"
} }
@ -300,6 +309,7 @@ fi
chdir= chdir=
NO_CACHE= NO_CACHE=
FAKE=
args=( args=(
--help '$exit_with display_help' --help '$exit_with display_help'
-d:,--chdir: chdir= -d:,--chdir: chdir=
@ -307,6 +317,7 @@ args=(
-P,--prod PROFILE=prod -P,--prod PROFILE=prod
-T,--test PROFILE=test -T,--test PROFILE=test
-j,--no-cache NO_CACHE=1 -j,--no-cache NO_CACHE=1
-n,--fake FAKE=1
) )
parse_args "$@"; set -- "${args[@]}" parse_args "$@"; set -- "${args[@]}"