Refactor
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 29s
Webapp Test / Run webapp test suite (pull_request) Successful in 2m53s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m16s
Smoke Test / Run basic test suite (pull_request) Successful in 2m50s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 9m11s

This commit is contained in:
Thomas E Lackey 2024-02-23 19:41:03 -06:00
parent 61d254cd6c
commit 3194ebf8a6

View File

@ -95,7 +95,7 @@ def process_app_deployment_request(
deployment_config_file = os.path.join(deployment_dir, "config.env")
# TODO: Is there any reason not to simplify the hash input to the app_deployment_crn?
deployment_container_unique_tag = "laconic-webapp/%s:local" % hashlib.md5(deployment_dir.encode()).hexdigest()
deployment_container_shared_tag = f"laconic-webapp/{app.id}:local"
app_image_shared_tag = f"laconic-webapp/{app.id}:local"
# b. check for deployment directory (create if necessary)
if not os.path.exists(deployment_dir):
if deployment_record:
@ -112,17 +112,17 @@ def process_app_deployment_request(
# 6. build container (if needed)
if not deployment_record or deployment_record.attributes.application != app.id:
# check if the image already exists
if force_rebuild or not remote_image_exists(image_registry, deployment_container_shared_tag):
if force_rebuild or not remote_image_exists(image_registry, app_image_shared_tag):
# TODO: pull from request
extra_build_args = []
build_container_image(app, deployment_container_shared_tag, extra_build_args, log_file)
build_container_image(app, app_image_shared_tag, extra_build_args, log_file)
push_container_image(deployment_dir, log_file)
built_images = True
needs_k8s_deploy = True
# 7. Add tags (as needed)
if built_images or not remote_image_exists(image_registry, deployment_container_unique_tag):
add_tags_to_image(image_registry, deployment_container_shared_tag, deployment_container_unique_tag)
add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_unique_tag)
# 8. update config (if needed)
if not deployment_record or file_hash(deployment_config_file) != deployment_record.attributes.meta.config: