From 39bf0e2795d5ba8f9f9824f58688d0eb63e58fd6 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 23 Feb 2024 20:58:33 -0600 Subject: [PATCH] refactor --- .../deploy/webapp/deploy_webapp_from_registry.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index 65dcb748..027a76b3 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -94,7 +94,7 @@ def process_app_deployment_request( deployment_dir = os.path.join(deployment_parent_dir, fqdn) 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_tag = "laconic-webapp/%s:local" % hashlib.md5(deployment_dir.encode()).hexdigest() 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): @@ -102,7 +102,7 @@ def process_app_deployment_request( raise Exception("Deployment record %s exists, but not deployment dir %s. Please remove name." % (app_deployment_crn, deployment_dir)) print("deploy_webapp", deployment_dir) - deploy_webapp.create_deployment(ctx, deployment_dir, deployment_container_unique_tag, + deploy_webapp.create_deployment(ctx, deployment_dir, deployment_container_tag, f"https://{fqdn}", kube_config, image_registry, env_filename) elif env_filename: shutil.copyfile(env_filename, deployment_config_file) @@ -115,15 +115,15 @@ def process_app_deployment_request( shared_tag_exists = remote_image_exists(image_registry, app_image_shared_tag) if shared_tag_exists and not force_rebuild: # simply add our unique tag to the existing image and we are done - print(f"Using existing app image {app_image_shared_tag} for {deployment_container_unique_tag}", file=log_file) - add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_unique_tag) + print(f"Using existing app image {app_image_shared_tag} for {deployment_container_tag}", file=log_file) + add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_tag) else: extra_build_args = [] # TODO: pull from request - build_container_image(app, deployment_container_unique_tag, extra_build_args, log_file) + build_container_image(app, deployment_container_tag, extra_build_args, log_file) push_container_image(deployment_dir, log_file) # The build/push commands above will use the unique deployment tag, so now we need to add the shared tag. - print(f"Updating app image tag {app_image_shared_tag} from build of {deployment_container_unique_tag}", file=log_file) - add_tags_to_image(image_registry, deployment_container_unique_tag, app_image_shared_tag) + print(f"Updating app image tag {app_image_shared_tag} from build of {deployment_container_tag}", file=log_file) + add_tags_to_image(image_registry, deployment_container_tag, app_image_shared_tag) # 7. update config (if needed) if not deployment_record or file_hash(deployment_config_file) != deployment_record.attributes.meta.config: