From d342462a3d05555cda1af8361b1a10508f8bdddf Mon Sep 17 00:00:00 2001 From: wangbo Date: Tue, 28 Jul 2026 04:59:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E5=85=BC=E5=AE=B9=20macOS=20Bas?= =?UTF-8?q?h=203.2=20=E4=B8=8B=E8=BD=BD=E5=B9=B3=E5=8F=B0=E6=B8=85?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 operator URL 与固定 SHA-256 从关联数组改为并行索引数组,避免 macOS Bash 3.2 将带连字符的文件名解析为算术变量。远端资源复制前仍逐项校验 checksum。 验证:bash -n、ShellCheck、Bash 3.2 索引遍历。 --- scripts/cluster/bootstrap-platform.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/cluster/bootstrap-platform.sh b/scripts/cluster/bootstrap-platform.sh index d226660..4f26d7e 100755 --- a/scripts/cluster/bootstrap-platform.sh +++ b/scripts/cluster/bootstrap-platform.sh @@ -46,20 +46,22 @@ source "$postgres_environment" exit 1 } -declare -A operator_urls=( - [cert-manager.yaml]=https://github.com/cert-manager/cert-manager/releases/download/v1.21.0/cert-manager.yaml - [cnpg.yaml]=https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.29/releases/cnpg-1.29.1.yaml - [barman.yaml]=https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v0.13.0/manifest.yaml +operators=(cert-manager.yaml cnpg.yaml barman.yaml) +operator_urls=( + https://github.com/cert-manager/cert-manager/releases/download/v1.21.0/cert-manager.yaml + https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.29/releases/cnpg-1.29.1.yaml + https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v0.13.0/manifest.yaml ) -declare -A operator_checksums=( - [cert-manager.yaml]=6e499c3f1ab356abe79a7853911f80cb09c213885bfdf81092fdff142ba63c4a - [cnpg.yaml]=e0c5ff41bf5b01c0775bf225929b8423d543cd23e9742e4274fe7de8499cf93a - [barman.yaml]=d2e71e7b06822448f1a421f05781846cfdb9cc621e7ef32eef5e20c5133213b0 +operator_checksums=( + 6e499c3f1ab356abe79a7853911f80cb09c213885bfdf81092fdff142ba63c4a + e0c5ff41bf5b01c0775bf225929b8423d543cd23e9742e4274fe7de8499cf93a + d2e71e7b06822448f1a421f05781846cfdb9cc621e7ef32eef5e20c5133213b0 ) -for operator in cert-manager.yaml cnpg.yaml barman.yaml; do - curl -fsSL "${operator_urls[$operator]}" -o "$working_directory/$operator" +for index in 0 1 2; do + operator=${operators[$index]} + curl -fsSL "${operator_urls[$index]}" -o "$working_directory/$operator" actual_checksum=$(shasum -a 256 "$working_directory/$operator" | awk '{print $1}') - [[ $actual_checksum == "${operator_checksums[$operator]}" ]] || { + [[ $actual_checksum == "${operator_checksums[$index]}" ]] || { echo "operator manifest checksum mismatch: $operator" >&2 exit 1 }