kas-container: Factor out clean into a separate function
The logic will grow, and this better happens outside of the command line parser. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
5297f7d1f3
commit
833a65124e
@ -87,6 +87,20 @@ enable_isar_mode() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_clean() {
|
||||||
|
if [ -n "${KAS_ISAR_ARGS}" ]; then
|
||||||
|
set_container_image_var
|
||||||
|
# SC2086: Double quote to prevent globbing and word splitting.
|
||||||
|
# shellcheck disable=2086
|
||||||
|
trace ${KAS_CONTAINER_COMMAND} run -v "${KAS_BUILD_DIR}":/build:rw \
|
||||||
|
--workdir=/build --rm ${KAS_ISAR_ARGS} \
|
||||||
|
${KAS_CONTAINER_IMAGE} \
|
||||||
|
sudo rm -rf tmp
|
||||||
|
else
|
||||||
|
trace rm -rf "${KAS_BUILD_DIR}/tmp"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
KAS_IMAGE_VERSION_DEFAULT="2.6.3"
|
KAS_IMAGE_VERSION_DEFAULT="2.6.3"
|
||||||
KAS_CONTAINER_IMAGE_PATH_DEFAULT="ghcr.io/siemens/kas"
|
KAS_CONTAINER_IMAGE_PATH_DEFAULT="ghcr.io/siemens/kas"
|
||||||
KAS_CONTAINER_IMAGE_NAME_DEFAULT="kas"
|
KAS_CONTAINER_IMAGE_NAME_DEFAULT="kas"
|
||||||
@ -208,17 +222,7 @@ while [ $# -gt 0 ]; do
|
|||||||
;;
|
;;
|
||||||
clean)
|
clean)
|
||||||
[ $# -eq 1 ] || usage
|
[ $# -eq 1 ] || usage
|
||||||
if [ -n "${KAS_ISAR_ARGS}" ]; then
|
run_clean "$1"
|
||||||
set_container_image_var
|
|
||||||
# SC2086: Double quote to prevent globbing and word splitting.
|
|
||||||
# shellcheck disable=2086
|
|
||||||
trace ${KAS_CONTAINER_COMMAND} run -v "${KAS_BUILD_DIR}":/build:rw \
|
|
||||||
--workdir=/build --rm ${KAS_ISAR_ARGS} \
|
|
||||||
${KAS_CONTAINER_IMAGE} \
|
|
||||||
sudo rm -rf tmp
|
|
||||||
else
|
|
||||||
trace rm -rf "${KAS_BUILD_DIR}/tmp"
|
|
||||||
fi
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
shell)
|
shell)
|
||||||
|
Loading…
Reference in New Issue
Block a user