Add fresh device trust, installer recovery and scoped patch runtime
This commit is contained in:
@@ -95,10 +95,11 @@ def activate(payload):
|
||||
run('docker','build','--network=none','--pull=false','-t',tag,str(context))
|
||||
overlay=role_dir/'image.compose.yaml'
|
||||
write_atomic(overlay,('services:\n'+''.join(f' {r}:\n image: {tag}\n pull_policy: never\n' for r in ('migrate','api','gateway'))).encode())
|
||||
for path in payload['overlays']:
|
||||
file=(root/'deploy')/path
|
||||
if not re.fullmatch(r'[\w.-]+\.compose\.yaml',path) or not file.is_file():
|
||||
raise ValueError('Dev compose overlay must exist in the deployment directory')
|
||||
for path, content in payload['overlays'].items():
|
||||
file = (root / 'deploy') / path
|
||||
if not re.fullmatch(r'server\.[\w.-]+\.compose\.yaml', path) or file.is_symlink():
|
||||
raise ValueError('Invalid development overlay name')
|
||||
write_atomic(file, base64.b64decode(content, validate=True))
|
||||
if file not in base_files:
|
||||
compose.extend(['-f',str(file)])
|
||||
compose.extend(['-f',str(overlay)])
|
||||
@@ -150,7 +151,7 @@ def main():
|
||||
import shlex
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--ref',required=True)
|
||||
parser.add_argument('--overlay',action='append',default=[],help='Additional existing compose file in remote deploy/')
|
||||
parser.add_argument('--overlay',action='append',default=[],help='Deploy and use this compose overlay from the selected Git revision')
|
||||
args=parser.parse_args()
|
||||
revision=subprocess.check_output(['git','rev-parse','--verify','--end-of-options',args.ref+'^{commit}'],text=True).strip()
|
||||
web=web_files(revision)
|
||||
@@ -158,7 +159,13 @@ def main():
|
||||
names=subprocess.check_output(['git','ls-tree','--name-only','-r',revision,'migrations'],text=True).splitlines()
|
||||
migrations={str(int(Path(n).name.split('_',1)[0])):hashlib.sha384(subprocess.check_output(['git','show',revision+':'+n])).hexdigest()
|
||||
for n in names if n.endswith('.sql')}
|
||||
payload=json.dumps(dict(revision=revision,web=web,overlays=args.overlay,migrations=migrations))
|
||||
overlays = {}
|
||||
for name in args.overlay:
|
||||
if not re.fullmatch(r'server\.[\w.-]+\.compose\.yaml', name):
|
||||
parser.error('Expected a server overlay filename from deploy/')
|
||||
raw = subprocess.check_output(['git', 'show', revision + ':deploy/' + name])
|
||||
overlays[name] = base64.b64encode(raw).decode()
|
||||
payload=json.dumps(dict(revision=revision,web=web,overlays=overlays,migrations=migrations))
|
||||
cmd=source+'\nactivate(json.loads('+repr(payload)+'))\n'
|
||||
subprocess.run(ssh_prefix('server')+[shlex.join(['python3','-I','-'])],input=cmd,text=True,check=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user