Fix B2 foundation proof for Compose omitted false bind option

This commit is contained in:
Codex
2026-09-30 16:29:26 +03:00
parent 9dcd520503
commit 1e191868be
8 changed files with 328 additions and 4 deletions
+11 -4
View File
@@ -42805,7 +42805,7 @@ def main(argv):
# Additive external VPS management foundation. The payload never contains keys.
DEVICE_B2_ID = 'device-b2-foundation-v1-20260930-001'
DEVICE_B2_ID = 'device-b2-foundation-v1-20260930-002'
DEVICE_B2_DESCRIPTOR = 'deployment/device-b2-foundation-v1.json'
DEVICE_B2_SQL = 'deployment/device-b2-foundation-v1.sql'
DEVICE_B2_OVERRIDE = 'docker-compose.device-b2-foundation.yml'
@@ -42948,12 +42948,19 @@ def device_b2_config_proof(base, candidate):
core.setdefault('volumes', []).append({'type': 'bind', 'source': str(DEVICE_B2_SECRET_ROOT),
'target': DEVICE_B2_DESTINATION, 'bind': {'create_host_path': False}})
actual = json.loads(json.dumps(candidate))
# Compose versions can explicitly serialize read_only:false or omit it.
# Compose 2.20.1 omits false booleans, including create_host_path inside
# bind:{}. Normalize only the approved new mount in comparison copies.
# The fixed source YAML still requires create_host_path:false. True, null,
# non-booleans, other bind options and all existing mounts stay exact.
for value in (expected, actual):
volumes = value['services']['device-control-core'].get('volumes', [])
for v in volumes:
if v.get('target') == DEVICE_B2_DESTINATION and v.get('read_only') is False:
v.pop('read_only')
if v.get('target') == DEVICE_B2_DESTINATION:
if v.get('read_only') is False:
v.pop('read_only')
bind = v.get('bind')
if isinstance(bind, dict) and bind.get('create_host_path') is False:
bind.pop('create_host_path')
volumes.sort(key=lambda v: v['target'])
if expected != actual:
die('Device B2 foundation changes more than its one private mount/environment entry')