functions : add pod functions

This commit is contained in:
Gitouche 2021-06-04 15:33:24 +02:00
parent 3c7ab1546c
commit 91f9bf171d
1 changed files with 50 additions and 0 deletions

View File

@ -141,3 +141,53 @@ ensure_container_not_running () {
return 0
fi
}
# check: pod $1 exists?
check_pod_exists () {
podman pod exists ${1}
}
# ok if pod exists
ensure_pod_exists () {
if ! check_pod_exists ${1}; then
echo "ERROR : pod ${1} does not exists"
exit 1
else
return 0
fi
}
# ok if pod does not exists
ensure_pod_not_exists () {
if check_pod_exists ${1}; then
echo "ERROR : pod ${1} exists"
exit 1
else
return 0
fi
}
# check: pod ${1} is running?
check_pod_running () {
[[ "podman pod inspect -f '{{.State}}' ${1}" == "Running" ]]
}
# ok if pod is running
ensure_pod_running () {
if ! check_pod_running ${1}; then
echo "ERROR : pod ${1} is not running"
exit 1
else
return 0
fi
}
# ok if pod is not running
ensure_pod_not_running () {
if check_pod_running ${1}; then
echo "ERROR : pod ${1} is running"
exit 1
else
return 0
fi
}