Skip to content

Commit b123375

Browse files
author
Pablo Garcia Miranda
committed
Adding variable IS_VCLUSTER to easily check in all the if statements
1 parent 3ba83af commit b123375

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

kind/deploy-netbox.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ fi
1515
CLUSTER=$1
1616
VERSION=$2
1717
NAMESPACE=$3
18-
VCLUSTER_MODE=${4:-}
18+
19+
# Treat the optional fourth argument "--vcluster" as a boolean flag
20+
IS_VCLUSTER=false
21+
if [[ "${4:-}" == "--vcluster" ]]; then
22+
IS_VCLUSTER=true
23+
fi
1924

2025
# Choose kubectl and helm commands depending if we run on vCluster
21-
if [[ "$VCLUSTER_MODE" == "--vcluster" ]]; then
26+
if $IS_VCLUSTER; then
2227
KUBECTL="vcluster connect ${CLUSTER} -n ${NAMESPACE} -- kubectl"
2328
HELM="vcluster connect ${CLUSTER} -n ${NAMESPACE} -- helm"
2429
else
@@ -80,7 +85,7 @@ else
8085
exit 1
8186
fi
8287

83-
if [[ "$VCLUSTER_MODE" == "--vcluster" ]]; then
88+
if $IS_VCLUSTER; then
8489
echo "[Running in vCluster mode] skipping docker pull and kind load for remote images."
8590
sleep 15
8691
else
@@ -97,7 +102,7 @@ docker build -t netbox-load-local-data:1.0 --load --no-cache --progress=plain -f
97102
cd -
98103

99104
# Load local images into Kind only if not vCluster
100-
if [[ "$VCLUSTER_MODE" != "--vcluster" ]]; then
105+
if ! $IS_VCLUSTER; then
101106
echo "Loading local images into kind cluster..."
102107
declare -a Local_Images=( \
103108
"netbox-load-local-data:1.0" \
@@ -121,9 +126,10 @@ ${HELM} upgrade --install postgres-operator \
121126
# Deploy the database
122127
${KUBECTL} apply --namespace="${NAMESPACE}" -f "$(dirname "$0")/netbox-db.yaml"
123128
${KUBECTL} wait --namespace="${NAMESPACE}" --timeout=600s --for=jsonpath='{.status.PostgresClusterStatus}'=Running postgresql/netbox-db
129+
124130
echo "loading demo-data into NetBox…"
125131

126-
if [[ "$VCLUSTER_MODE" == "--vcluster" ]]; then
132+
if $IS_VCLUSTER; then
127133
# — vCluster —
128134
echo " → inside the vcluster"
129135
kubectl create configmap netbox-demo-data-load-job-scripts \

0 commit comments

Comments
 (0)