Commit 6372bb2f authored by Ismo Puustinen's avatar Ismo Puustinen

cluster/gce: fix checks for empty strings.

In order to use -n, the value needs either be quoted or [[ .. ]] block has to be used. Fix the comparisons that way. To verify, consider this (analogous) script: #!/bin/bash subnetwork_url="" if [ -n ${subnetwork_url} ]; then echo "foo" fi if [[ -n ${subnetwork_url} ]]; then echo "bar" fi Here "foo" is echoed by the script, even though the variable subnetwork_url has a zero-length value.
parent 2226b1de
......@@ -81,10 +81,10 @@ flex_clean() {
umount_silent ${MOUNTER_PATH}
rm -rf ${MOUNTER_PATH}
if [ -n ${IMAGE_URL:-} ]; then
if [[ -n ${IMAGE_URL:-} ]]; then
docker rmi -f ${IMAGE_URL} &> /dev/null || /bin/true
fi
if [ -n ${MOUNTER_DEFAULT_NAME:-} ]; then
if [[ -n ${MOUNTER_DEFAULT_NAME:-} ]]; then
docker rm -f ${MOUNTER_DEFAULT_NAME} &> /dev/null || /bin/true
fi
}
......
......@@ -53,7 +53,7 @@ function detect-k8s-subnetwork() {
local subnetwork_url=$(gcloud compute instances describe \
${KUBE_MASTER} --project=${PROJECT} --zone=${ZONE} \
--format='value(networkInterfaces[0].subnetwork)')
if [ -n ${subnetwork_url} ]; then
if [[ -n ${subnetwork_url} ]]; then
IP_ALIAS_SUBNETWORK=$(echo ${subnetwork_url##*/})
fi
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment