Skip to content

Commit fcd51a8

Browse files
committed
Using jq to parse the default CNI for improved script robustness
1 parent 3895e33 commit fcd51a8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

charts/spiderpool/templates/configmap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ data:
172172
cat /host/etc/cni/net.d/${DEFAULT_CNI_FILEPATH}
173173
174174
echo ""
175-
DEFAULT_CNI_NAME=$(grep '"name":' ${CNI_CONF_DIR}/${DEFAULT_CNI_FILEPATH} | awk '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d ',' | tr -d '"')
175+
176+
DEFAULT_CNI_NAME=$(jq -r '.name' ${CNI_CONF_DIR}/${DEFAULT_CNI_FILEPATH})
176177
if [ -z "$DEFAULT_CNI_NAME" ] ; then
177178
error "The name fleid shouldn't be empty, please check the default cni: ${DEFAULT_CNI_FILEPATH}" && exit 1
178179
fi

images/spiderpool-base/install-others.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ packages=(
1414
libmnl0
1515
bash-completion
1616
iptables
17+
jq
1718
)
1819

1920

0 commit comments

Comments
 (0)