Skip to content

Commit 88508a0

Browse files
authored
fix(scripts): replace mapfile with bash 3.2-compatible read loop in helm-k3s-local (#1539)
macOS ships bash 3.2 which lacks mapfile/readarray. Replace all three occurrences in configure_ghcr_credentials, cluster_has_image, and cluster_image_platform with a portable while-read loop, consistent with the fix applied to docker-build-image.sh in #1334.
1 parent 4848c40 commit 88508a0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tasks/scripts/helm-k3s-local.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ configure_ghcr_credentials() {
149149
registries_content="$(printf 'configs:\n "ghcr.io":\n auth:\n username: %s\n password: %s\n' \
150150
"${GITHUB_USERNAME}" "${GITHUB_PAT}")"
151151

152-
local -a nodes
153-
mapfile -t nodes < <(docker ps --format '{{.Names}}' \
152+
local -a nodes=()
153+
while IFS= read -r _node; do nodes+=("$_node"); done < <(docker ps --format '{{.Names}}' \
154154
--filter "name=k3d-${CLUSTER_NAME}-server-" 2>/dev/null || true)
155155

156156
if [[ ${#nodes[@]} -eq 0 ]]; then
@@ -168,8 +168,8 @@ configure_ghcr_credentials() {
168168

169169
cluster_has_image() {
170170
local image="$1"
171-
local -a nodes
172-
mapfile -t nodes < <(docker ps --format '{{.Names}}' \
171+
local -a nodes=()
172+
while IFS= read -r _node; do nodes+=("$_node"); done < <(docker ps --format '{{.Names}}' \
173173
--filter "name=k3d-${CLUSTER_NAME}-server-" 2>/dev/null || true)
174174

175175
for node in "${nodes[@]}"; do
@@ -182,8 +182,8 @@ cluster_has_image() {
182182
}
183183

184184
cluster_image_platform() {
185-
local -a nodes
186-
mapfile -t nodes < <(docker ps --format '{{.Names}}' \
185+
local -a nodes=()
186+
while IFS= read -r _node; do nodes+=("$_node"); done < <(docker ps --format '{{.Names}}' \
187187
--filter "name=k3d-${CLUSTER_NAME}-server-" 2>/dev/null || true)
188188

189189
if [[ ${#nodes[@]} -gt 0 ]]; then

0 commit comments

Comments
 (0)