Skip to content

Commit a8ac397

Browse files
committed
fix(e2e): regenerate gateway config via TOML for docker + podman harnesses
The gateway CLI flags moved into TOML config tables in 560550d (#1394), which made every existing e2e/with-{docker,podman}-gateway.sh invocation fail with "unexpected argument '--sandbox-namespace'" (and a long tail of similar driver-specific options) before the gateway could even bind. Replace the obsolete CLI flags with a synthesized `[openshell.drivers.<driver>]` table written to `${STATE_DIR}/gateway.toml` and passed via the new `--config` flag. Only the gateway-wide flags that survived 560550d (bind-address, port, drivers, db-url, tls-*, disable-tls, log-level, health-port) stay on the command line. Both scripts get a small `toml_string` helper to properly TOML-quote the values (the previous `%q` printf format produced bash-escape, not TOML-escape). The Docker harness also corrects two field names that diverged from the driver schema: `docker_network_name` → `network_name`, and the supervisor binary/image plumbing now reads through to `supervisor_bin` / `supervisor_image` in the same table. The Podman harness drops `--ssh-gateway-port` (deleted in 560550d — gRPC + SSH are multiplexed on the same port now) and substitutes `network_name` + `gateway_port` for the obsolete `--sandbox-namespace` (which the Podman driver never had as a typed field).
1 parent 560550d commit a8ac397

2 files changed

Lines changed: 79 additions & 23 deletions

File tree

e2e/with-docker-gateway.sh

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -448,27 +448,61 @@ else
448448
fi
449449

450450
echo "Starting openshell-gateway on port ${HOST_PORT} (namespace: ${E2E_NAMESPACE})..."
451+
452+
# Driver-specific options moved from CLI flags into a TOML config table
453+
# (commit 560550d2). Synthesize a minimal config here and pass --config.
454+
# Quote a value as a TOML basic string: wrap in double quotes and escape
455+
# any embedded backslashes / double quotes. Adequate for paths, image
456+
# refs, and namespace identifiers — none of which contain TOML special
457+
# characters in practice.
458+
toml_string() {
459+
local value="$1"
460+
value="${value//\\/\\\\}"
461+
value="${value//\"/\\\"}"
462+
printf '"%s"' "${value}"
463+
}
464+
465+
GATEWAY_CONFIG="${STATE_DIR}/gateway.toml"
466+
{
467+
printf '[openshell]\nversion = 1\n\n'
468+
printf '[openshell.gateway]\nlog_level = "info"\n\n'
469+
printf '[openshell.drivers.docker]\n'
470+
printf 'sandbox_namespace = %s\n' "$(toml_string "${E2E_NAMESPACE}")"
471+
printf 'network_name = %s\n' "$(toml_string "${DOCKER_NETWORK_NAME}")"
472+
printf 'grpc_endpoint = %s\n' "$(toml_string "${GATEWAY_ENDPOINT}")"
473+
printf 'default_image = %s\n' "$(toml_string "${SANDBOX_IMAGE}")"
474+
printf 'image_pull_policy = "IfNotPresent"\n'
475+
printf 'guest_tls_ca = %s\n' "$(toml_string "${PKI_DIR}/ca.crt")"
476+
printf 'guest_tls_cert = %s\n' "$(toml_string "${PKI_DIR}/client.crt")"
477+
printf 'guest_tls_key = %s\n' "$(toml_string "${PKI_DIR}/client.key")"
478+
# DOCKER_SUPERVISOR_ARGS holds either ("--docker-supervisor-bin" "<path>")
479+
# or ("--docker-supervisor-image" "<image>"); both map to TOML keys on
480+
# the docker driver config.
481+
for ((i=0; i<${#DOCKER_SUPERVISOR_ARGS[@]}; i+=2)); do
482+
case "${DOCKER_SUPERVISOR_ARGS[$i]}" in
483+
--docker-supervisor-bin)
484+
printf 'supervisor_bin = %s\n' "$(toml_string "${DOCKER_SUPERVISOR_ARGS[$((i+1))]}")"
485+
;;
486+
--docker-supervisor-image)
487+
printf 'supervisor_image = %s\n' "$(toml_string "${DOCKER_SUPERVISOR_ARGS[$((i+1))]}")"
488+
;;
489+
esac
490+
done
491+
if [ -n "${GATEWAY_HOST_ALIAS_IP}" ]; then
492+
printf 'host_gateway_ip = %s\n' "$(toml_string "${GATEWAY_HOST_ALIAS_IP}")"
493+
fi
494+
} > "${GATEWAY_CONFIG}"
495+
451496
GATEWAY_ARGS=(
452-
--bind-address 0.0.0.0 \
453-
--port "${HOST_PORT}" \
454-
--drivers docker \
455-
--sandbox-namespace "${E2E_NAMESPACE}" \
456-
--docker-network-name "${DOCKER_NETWORK_NAME}" \
457-
--tls-cert "${PKI_DIR}/server.crt" \
458-
--tls-key "${PKI_DIR}/server.key" \
459-
--tls-client-ca "${PKI_DIR}/ca.crt" \
460-
--db-url "sqlite:${STATE_DIR}/gateway.db?mode=rwc" \
461-
--grpc-endpoint "${GATEWAY_ENDPOINT}" \
462-
"${DOCKER_SUPERVISOR_ARGS[@]}" \
463-
--docker-tls-ca "${PKI_DIR}/ca.crt" \
464-
--docker-tls-cert "${PKI_DIR}/client.crt" \
465-
--docker-tls-key "${PKI_DIR}/client.key" \
466-
--sandbox-image "${SANDBOX_IMAGE}" \
467-
--sandbox-image-pull-policy IfNotPresent
497+
--config "${GATEWAY_CONFIG}"
498+
--bind-address 0.0.0.0
499+
--port "${HOST_PORT}"
500+
--drivers docker
501+
--tls-cert "${PKI_DIR}/server.crt"
502+
--tls-key "${PKI_DIR}/server.key"
503+
--tls-client-ca "${PKI_DIR}/ca.crt"
504+
--db-url "sqlite:${STATE_DIR}/gateway.db?mode=rwc"
468505
)
469-
if [ -n "${GATEWAY_HOST_ALIAS_IP}" ]; then
470-
GATEWAY_ARGS+=(--host-gateway-ip "${GATEWAY_HOST_ALIAS_IP}")
471-
fi
472506

473507
e2e_write_gateway_args_file "${GATEWAY_ARGS_FILE}" "${GATEWAY_ARGS[@]}"
474508
e2e_export_gateway_restart_metadata \

e2e/with-podman-gateway.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,39 @@ export OPENSHELL_E2E_NETWORK_NAME="${PODMAN_NETWORK_NAME}"
326326
export OPENSHELL_E2E_SANDBOX_NAMESPACE="${E2E_NAMESPACE}"
327327

328328
echo "Starting openshell-gateway on port ${HOST_PORT} (namespace: ${E2E_NAMESPACE})..."
329+
330+
# Driver-specific options moved from CLI flags into a TOML config table
331+
# (commit 560550d2). Synthesize a minimal config here and pass --config.
332+
# Quote a value as a TOML basic string: see with-docker-gateway.sh for
333+
# the same helper (kept duplicated to avoid sourcing across e2e scripts).
334+
toml_string() {
335+
local value="$1"
336+
value="${value//\\/\\\\}"
337+
value="${value//\"/\\\"}"
338+
printf '"%s"' "${value}"
339+
}
340+
341+
GATEWAY_CONFIG="${STATE_DIR}/gateway.toml"
342+
{
343+
printf '[openshell]\nversion = 1\n\n'
344+
printf '[openshell.gateway]\nlog_level = "info"\n\n'
345+
printf '[openshell.drivers.podman]\n'
346+
# The Podman driver scopes isolation by network rather than namespace.
347+
printf 'network_name = %s\n' "$(toml_string "${PODMAN_NETWORK_NAME}")"
348+
printf 'gateway_port = %s\n' "${HOST_PORT}"
349+
printf 'default_image = %s\n' "$(toml_string "${SANDBOX_IMAGE}")"
350+
printf 'image_pull_policy = "missing"\n'
351+
printf 'supervisor_image = %s\n' "$(toml_string "${SUPERVISOR_IMAGE}")"
352+
} > "${GATEWAY_CONFIG}"
353+
329354
GATEWAY_ARGS=(
355+
--config "${GATEWAY_CONFIG}"
330356
--bind-address 0.0.0.0
331357
--port "${HOST_PORT}"
332358
--health-port "${HEALTH_PORT}"
333-
--ssh-gateway-port "${HOST_PORT}"
334359
--drivers podman
335360
--disable-tls
336361
--db-url "sqlite:${STATE_DIR}/gateway.db?mode=rwc"
337-
--sandbox-namespace "${E2E_NAMESPACE}"
338-
--sandbox-image "${SANDBOX_IMAGE}"
339-
--sandbox-image-pull-policy missing
340362
--log-level info
341363
)
342364

0 commit comments

Comments
 (0)