mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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.
This commit is contained in:
parent
2226b1de09
commit
6372bb2f28
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user