Skip to content

Commit 157525b

Browse files
committed
Using jq to parse the default CNI for improved script robustness (spidernet-io#5183)
Signed-off-by: Cyclinder Kuo <[email protected]>
1 parent 2f83ecf commit 157525b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

charts/spiderpool/templates/configmap.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ 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
179180
180181
log "Updating the clusterNetwork of the multus-cni config to $DEFAULT_CNI_NAME"
181-
sed -i "s?\"clusterNetwork\": \"\"?\"clusterNetwork\": \"${DEFAULT_CNI_NAME}\"?g" /tmp/00-multus.conf
182+
jq ".clusterNetwork=\"${DEFAULT_CNI_NAME}\"" /tmp/00-multus.conf > /tmp/00-multus.conf.tmp && mv /tmp/00-multus.conf.tmp /tmp/00-multus.conf
182183
else
183184
log "User set multus ClusterNetwork: $MULTUS_CLUSTER_NETWORK"
184185
fi

images/spiderpool-agent/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Copyright 2022 Authors of spidernet-io
22
# SPDX-License-Identifier: Apache-2.0
33

4-
ARG BASE_IMAGE=ghcr.io/spidernet-io/spiderpool/spiderpool-base:163aca9e9d927363fa80aca7d9721b379671a790
5-
ARG GOLANG_IMAGE=docker.io/library/golang:1.24.2
4+
ARG BASE_IMAGE=ghcr.io/spidernet-io/spiderpool/spiderpool-base:e5de792a4214e67a4d10a6faf476fef3d9f043ca
5+
ARG GOLANG_IMAGE=docker.io/library/golang:1.24.5@sha256:14fd8a55e59a560704e5fc44970b301d00d344e45d6b914dda228e09f359a088
66

77
#======= build bin ==========
88
FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} AS builder

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)