This commit is contained in:
Thomas E Lackey 2023-12-04 10:47:25 -06:00
parent 07ef08631d
commit 992196eca0
2 changed files with 17 additions and 7 deletions

View File

@ -79,8 +79,17 @@ def redeploy(app_record, deploy_record, deploy_crn, deployment_dir):
version = "0.0.%d" % (int(deploy_record["attributes"]["version"].split(".")[-1]) + 1) version = "0.0.%d" % (int(deploy_record["attributes"]["version"].split(".")[-1]) + 1)
meta = { meta = {
"record": {"type": "WebAppDeploymentRecord", "version": version, "url": f"http://{hostname}", "name": hostname, "record": {
"application": app_record["id"], "meta": {"config": config_hash(deployment_dir)}, }} "type": "WebAppDeploymentRecord",
"version": version,
"url": f"http://{hostname}",
"name": hostname,
"application": app_record["id"],
"meta": {
"config": config_hash(deployment_dir)
},
}
}
tmpdir = tempfile.mkdtemp() tmpdir = tempfile.mkdtemp()
try: try:
@ -91,9 +100,9 @@ def redeploy(app_record, deploy_record, deploy_crn, deployment_dir):
print(open(record_fname, 'r').read()) print(open(record_fname, 'r').read())
print("Updating deployment record ...") print("Updating deployment record ...")
new_record_id = \ new_record_id = json.loads(
json.loads(cmd("laconic", "-c", args.laconic_config, "cns", "record", "publish", "--filename", record_fname))[ cmd("laconic", "-c", args.laconic_config, "cns", "record", "publish", "--filename", record_fname)
"id"] )["id"]
print("Updating deployment registered name ...") print("Updating deployment registered name ...")
cmd("laconic", "-c", args.laconic_config, "cns", "name", "set", deploy_crn, new_record_id) cmd("laconic", "-c", args.laconic_config, "cns", "name", "set", deploy_crn, new_record_id)
finally: finally:
@ -119,7 +128,7 @@ app_record = json.loads(cmd("laconic", "-c", args.laconic_config, "cns", "name",
# compare # compare
try: try:
deploy_record = json.loads(cmd("laconic", "-c", args.laconic_config, "cns", "name", "resolve", args.deploy_crn))[0] deploy_record = json.loads(cmd("laconic", "-c", args.laconic_config, "cns", "name", "resolve", args.deploy_crn))[0]
except: except: # noqa: E722
deploy_record = {} deploy_record = {}
needs_update = False needs_update = False
@ -128,7 +137,7 @@ if app_record["id"] == deploy_record.get("attributes", {}).get("application"):
print("Deployment %s already has latest application: %s" % (args.deploy_crn, app_record["id"])) print("Deployment %s already has latest application: %s" % (args.deploy_crn, app_record["id"]))
else: else:
print("Found updated application record eligible for deployment %s (old: %s, new: %s)" % ( print("Found updated application record eligible for deployment %s (old: %s, new: %s)" % (
args.deploy_crn, deploy_record.get("id"), app_record["id"])) args.deploy_crn, deploy_record.get("id"), app_record["id"]))
build_image(app_record, args.deployment_dir) build_image(app_record, args.deployment_dir)
needs_update = True needs_update = True

View File

@ -0,0 +1 @@
PyYAML>=6.0.1