ci: allow CONTAINER_CMD prefixed with sudo

Allow passing:
$ CONTAINER_CMD="sudo docker" ./scripts/minikube.sh cephcsi
or
$ CONTAINER_CMD="sudo podman" ./scripts/minikube.sh cephcsi

Because the container images could list in '# sudo docker images' or
'# sudo podman images' incase if the Makefile target image-cephcsi is
run with sudo

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever 2020-09-03 16:21:19 +05:30 committed by mergify[bot]
parent 6fa7b74138
commit bddf395eba

View File

@ -97,13 +97,14 @@ function install_kubectl() {
}
function validate_container_cmd() {
if [[ "${CONTAINER_CMD}" == "docker" ]] || [[ "${CONTAINER_CMD}" == "podman" ]]; then
if ! command -v "${CONTAINER_CMD}" &> /dev/null; then
echo "'${CONTAINER_CMD}' not found"
local cmd="${CONTAINER_CMD##* }"
if [[ "${cmd}" == "docker" ]] || [[ "${cmd}" == "podman" ]]; then
if ! command -v "${cmd}" &> /dev/null; then
echo "'${cmd}' not found"
exit 1
fi
else
echo "'CONTAINER_CMD' should be either docker or podman and not '${CONTAINER_CMD}'"
echo "'CONTAINER_CMD' should be either docker or podman and not '${cmd}'"
exit 1
fi
}