@@ -28,10 +28,12 @@ checkConfigExists() {
2828 # $3 configName
2929 case $CONFIG_STORAGE in
3030 nacos)
31- return checkNacosConfigExists " $@ "
31+ checkNacosConfigExists " $@ "
32+ return $?
3233 ;;
3334 file)
34- return checkFileConfigExists " $@ "
35+ checkFileConfigExists " $@ "
36+ return $?
3537 ;;
3638 * )
3739 printf " Unknown storage type: %s\n" " $CONFIG_STORAGE "
@@ -52,7 +54,7 @@ checkNacosConfigExists() {
5254 elif [ $statusCode -eq 404 ]; then
5355 return -1
5456 else
55- echo ${1 :- " Checking config ${group} /${dataId} in namespace ${NACOS_NS} failed with $retVal " }
57+ echo " Checking config ${group} /${dataId} in namespace ${NACOS_NS} failed with ${statusCode} "
5658 exit -1
5759 fi
5860}
@@ -62,7 +64,11 @@ checkFileConfigExists() {
6264 # $2 configType: plural
6365 # $3 configName
6466 local configFile=" ${FILE_ROOT_DIR} /$2 /$3 .yaml"
65- return [ -f " $configFile " ]
67+ if [ -f " $configFile " ]; then
68+ return 0
69+ else
70+ return 1
71+ fi
6672}
6773
6874getConfig () {
@@ -90,8 +96,6 @@ getNacosConfig() {
9096 local group=" $1 "
9197 local dataId=" $2 .$3 "
9298
93- echo " Group=$group DataId=$dataId "
94-
9599 config=" "
96100 tmpFile=$( mktemp /tmp/higress-precheck-nacos.XXXXXXXXX.cfg)
97101 statusCode=$( curl -s -o " $tmpFile " -w " %{http_code}" " ${NACOS_SERVER_URL} /v1/cs/configs?accessToken=${NACOS_ACCESS_TOKEN} &tenant=${NACOS_NS} &dataId=${dataId} &group=${group} " )
@@ -251,7 +255,6 @@ checkPilot() {
251255 IFS=$' \n '
252256 for fileName in $fileNames
253257 do
254- echo " FileName: $fileName "
255258 if [ -z " $fileName " ]; then
256259 continue
257260 fi
@@ -282,12 +285,12 @@ checkConsole() {
282285 echo " Checking console configurations..."
283286
284287 checkConfigExists " higress-system" " configmaps" " higress-console"
285- if [ ! $? ]; then
288+ if [ $? -ne 0 ]; then
286289 echo " The ConfigMap resource of Higress Console doesn't exist."
287290 exit -1
288291 fi
289292 checkConfigExists " higress-system" " secrets" " higress-console"
290- if [ ! $? ]; then
293+ if [ $? -ne 0 ]; then
291294 echo " The Secret resource of Higress Console doesn't exist."
292295 exit -1
293296 fi
0 commit comments