fix(deploy): 兼容 macOS Bash 3.2 下载平台清单

将 operator URL 与固定 SHA-256 从关联数组改为并行索引数组,避免 macOS Bash 3.2 将带连字符的文件名解析为算术变量。远端资源复制前仍逐项校验 checksum。

验证:bash -n、ShellCheck、Bash 3.2 索引遍历。
This commit is contained in:
2026-07-28 04:59:04 +08:00
parent 4e60bf1c64
commit d342462a3d
+13 -11
View File
@@ -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
}