mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
fix(deploy): forward documented gateway settings
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
|
||||
cd "$repo_root"
|
||||
|
||||
gateway_variables=$(mktemp "${TMPDIR:-/tmp}/sub2api-gateway-env.XXXXXX")
|
||||
cleanup() {
|
||||
rm -f "$gateway_variables"
|
||||
}
|
||||
trap cleanup EXIT HUP INT TERM
|
||||
|
||||
awk '
|
||||
/^GATEWAY_[A-Z0-9_]+=/ {
|
||||
separator = index($0, "=")
|
||||
print substr($0, 1, separator - 1) "\t" substr($0, separator + 1)
|
||||
}
|
||||
' deploy/.env.example > "$gateway_variables"
|
||||
|
||||
for compose_file in \
|
||||
deploy/docker-compose.yml \
|
||||
deploy/docker-compose.local.yml \
|
||||
deploy/docker-compose.standalone.yml \
|
||||
deploy/docker-compose.dev.yml
|
||||
do
|
||||
tab=$(printf '\t')
|
||||
while IFS="$tab" read -r key value; do
|
||||
expected=$(printf ' - %s=${%s:-%s}' "$key" "$key" "$value")
|
||||
count=$(grep -Fxc "$expected" "$compose_file" || true)
|
||||
if [ "$count" -ne 1 ]; then
|
||||
printf '%s must pass %s with the documented default exactly once\n' "$compose_file" "$key" >&2
|
||||
exit 1
|
||||
fi
|
||||
done < "$gateway_variables"
|
||||
done
|
||||
|
||||
printf 'docker compose Gateway environment test passed\n'
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
|
||||
cd "$repo_root"
|
||||
|
||||
expected=' - GATEWAY_OPENAI_WS_FORCE_HTTP=${GATEWAY_OPENAI_WS_FORCE_HTTP:-false}'
|
||||
|
||||
for compose_file in \
|
||||
deploy/docker-compose.yml \
|
||||
deploy/docker-compose.local.yml \
|
||||
deploy/docker-compose.standalone.yml \
|
||||
deploy/docker-compose.dev.yml
|
||||
do
|
||||
count=$(grep -Fxc "$expected" "$compose_file" || true)
|
||||
if [ "$count" -ne 1 ]; then
|
||||
printf '%s must pass GATEWAY_OPENAI_WS_FORCE_HTTP exactly once to sub2api\n' "$compose_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
printf 'docker compose OpenAI force HTTP environment test passed\n'
|
||||
Reference in New Issue
Block a user