fix(agent99): bind transport to Gitea source truth
This commit is contained in:
@@ -857,9 +857,10 @@ function Write-AgentResultAndExit {
|
||||
try {
|
||||
$envelope = $EnvelopeJson | ConvertFrom-Json
|
||||
if ([string]$envelope.schemaVersion -ne "agent99_remote_atomic_deploy_envelope_v1") { throw "invalid_envelope_schema" }
|
||||
if ([string]$envelope.sourceHostAlias -ne "110") { throw "invalid_source_host_alias" }
|
||||
if ([string]$envelope.sourceHostAlias -ne "gitea-main") { throw "invalid_source_host_alias" }
|
||||
if ([string]$envelope.targetHostAlias -ne "99") { throw "invalid_target_host_alias" }
|
||||
if ([string]$envelope.transport -ne "110_to_99_ssh_publickey") { throw "invalid_transport" }
|
||||
if ([string]$envelope.transport -ne "gitea_main_bound_controller_to_99_ssh_publickey") { throw "invalid_transport" }
|
||||
if ([string]$envelope.sourceHostGateSupersededBy -ne "global_product_governance_v2") { throw "invalid_source_host_gate_sunset" }
|
||||
$mode = [string]$envelope.mode
|
||||
if ($mode -notin @("check", "apply")) { throw "invalid_mode" }
|
||||
$transportPayloadMode = [string]$envelope.transportPayloadMode
|
||||
|
||||
@@ -4,7 +4,6 @@ set -euo pipefail
|
||||
readonly SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly DEFAULT_SOURCE_ROOT="$(CDPATH= cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
||||
readonly TARGET="Administrator@192.168.0.99"
|
||||
readonly SOURCE_HOST_IPV4="192.168.0.110"
|
||||
readonly GITEA_ORIGIN_HTTPS="https://gitea.wooo.work/wooo/awoooi.git"
|
||||
readonly GITEA_ORIGIN_HTTP_INTERNAL="http://192.168.0.110:3000/wooo/awoooi.git"
|
||||
readonly GITEA_ORIGIN_SSH_INTERNAL="ssh://git@192.168.0.110:2222/wooo/awoooi.git"
|
||||
@@ -150,20 +149,10 @@ if [[ "${MODE}" == "apply" ]]; then
|
||||
REMOTE_EXECUTION_TIMEOUT_SECONDS="2400"
|
||||
fi
|
||||
|
||||
for dependency in git python3 ssh scp mktemp hostname timeout; do
|
||||
for dependency in git python3 ssh scp mktemp timeout; do
|
||||
command -v "${dependency}" >/dev/null 2>&1 || fail "required_command_missing_${dependency}"
|
||||
done
|
||||
|
||||
SOURCE_HOST_VERIFIED=0
|
||||
read -r -a LOCAL_ADDRESSES <<<"$(hostname -I 2>/dev/null || true)"
|
||||
for local_address in "${LOCAL_ADDRESSES[@]}"; do
|
||||
if [[ "${local_address%%/*}" == "${SOURCE_HOST_IPV4}" ]]; then
|
||||
SOURCE_HOST_VERIFIED=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
[[ "${SOURCE_HOST_VERIFIED}" == "1" ]] || fail "source_host_is_not_110"
|
||||
|
||||
[[ -d "${SOURCE_ROOT}" ]] || fail "source_root_missing"
|
||||
SOURCE_ROOT="$(CDPATH= cd -- "${SOURCE_ROOT}" && pwd)"
|
||||
ORIGIN_URL="$(git -C "${SOURCE_ROOT}" remote get-url origin 2>/dev/null)" || fail "origin_remote_missing"
|
||||
@@ -261,9 +250,10 @@ preflight_content = preflight_path.read_bytes()
|
||||
|
||||
envelope = {
|
||||
"schemaVersion": "agent99_remote_atomic_deploy_envelope_v1",
|
||||
"sourceHostAlias": "110",
|
||||
"sourceHostAlias": "gitea-main",
|
||||
"targetHostAlias": "99",
|
||||
"transport": "110_to_99_ssh_publickey",
|
||||
"transport": "gitea_main_bound_controller_to_99_ssh_publickey",
|
||||
"sourceHostGateSupersededBy": "global_product_governance_v2",
|
||||
"transportPayloadMode": (
|
||||
"ephemeral_file_delete_before_receiver"
|
||||
if mode == "apply"
|
||||
|
||||
@@ -92,14 +92,28 @@ def test_sender_and_receiver_allow_exactly_the_deployer_runtime_bundle() -> None
|
||||
assert "duplicate_runtime_file" in receiver
|
||||
|
||||
|
||||
def test_sender_is_fixed_to_110_to_windows99_public_key_transport() -> None:
|
||||
def test_sender_is_fixed_to_gitea_main_and_windows99_public_key_transport() -> None:
|
||||
source = SENDER.read_text(encoding="utf-8")
|
||||
receiver = RECEIVER.read_text(encoding="utf-8")
|
||||
|
||||
assert 'readonly TARGET="Administrator@192.168.0.99"' in source
|
||||
assert 'readonly SOURCE_HOST_IPV4="192.168.0.110"' in source
|
||||
assert "source_host_is_not_110" in source
|
||||
assert '"sourceHostAlias": "110"' in source
|
||||
assert '"transport": "110_to_99_ssh_publickey"' in source
|
||||
assert "source_host_is_not_110" not in source
|
||||
assert "hostname -I" not in source
|
||||
assert '"sourceHostAlias": "gitea-main"' in source
|
||||
assert (
|
||||
'"transport": "gitea_main_bound_controller_to_99_ssh_publickey"'
|
||||
in source
|
||||
)
|
||||
assert (
|
||||
'"sourceHostGateSupersededBy": "global_product_governance_v2"'
|
||||
in source
|
||||
)
|
||||
assert 'sourceHostAlias -ne "gitea-main"' in receiver
|
||||
assert (
|
||||
'transport -ne "gitea_main_bound_controller_to_99_ssh_publickey"'
|
||||
in receiver
|
||||
)
|
||||
assert 'sourceHostGateSupersededBy -ne "global_product_governance_v2"' in receiver
|
||||
assert '"ephemeral_file_delete_before_receiver"' in source
|
||||
assert '"transportPayloadContainsSecrets": False' in source
|
||||
assert 'scp "${SCP_OPTIONS[@]}"' in source
|
||||
|
||||
Reference in New Issue
Block a user