From f90e0e2969754fe38eb9771c02305af38e3b46c1 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Mon, 26 Aug 2024 14:02:53 -0500 Subject: [PATCH] Unchanged. --- .../deploy/webapp/deploy_webapp.py | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp.py b/stack_orchestrator/deploy/webapp/deploy_webapp.py index 596274cf..4c91dec3 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp.py @@ -27,9 +27,7 @@ from stack_orchestrator.deploy.deploy_types import DeployCommandContext def _fixup_container_tag(deployment_dir: str, image: str): deployment_dir_path = Path(deployment_dir) - compose_file = deployment_dir_path.joinpath( - "compose", "docker-compose-webapp-template.yml" - ) + compose_file = deployment_dir_path.joinpath("compose", "docker-compose-webapp-template.yml") # replace "cerc/webapp-container:local" in the file with our image tag with open(compose_file) as rfile: contents = rfile.read() @@ -41,13 +39,13 @@ def _fixup_container_tag(deployment_dir: str, image: str): def _fixup_url_spec(spec_file_name: str, url: str): # url is like: https://example.com/path parsed_url = urlparse(url) - http_proxy_spec = f""" + http_proxy_spec = f''' http-proxy: - host-name: {parsed_url.hostname} routes: - path: '{parsed_url.path if parsed_url.path else "/"}' proxy-to: webapp:80 - """ + ''' spec_file_path = Path(spec_file_name) with open(spec_file_path) as rfile: contents = rfile.read() @@ -56,9 +54,7 @@ def _fixup_url_spec(spec_file_name: str, url: str): wfile.write(contents) -def create_deployment( - ctx, deployment_dir, image, url, kube_config, image_registry, env_file -): +def create_deployment(ctx, deployment_dir, image, url, kube_config, image_registry, env_file): # Do the equivalent of: # 1. laconic-so --stack webapp-template deploy --deploy-to k8s init --output webapp-spec.yml # --config (eqivalent of the contents of my-config.env) @@ -87,11 +83,17 @@ def create_deployment( kube_config, image_registry, spec_file_name, - None, + None ) # Add the TLS and DNS spec _fixup_url_spec(spec_file_name, url) - create_operation(deploy_command_context, spec_file_name, deployment_dir, None, None) + create_operation( + deploy_command_context, + spec_file_name, + deployment_dir, + None, + None + ) # Fix up the container tag inside the deployment compose file _fixup_container_tag(deployment_dir, image) os.remove(spec_file_name) @@ -100,7 +102,7 @@ def create_deployment( @click.group() @click.pass_context def command(ctx): - """manage a webapp deployment""" + '''manage a webapp deployment''' # Check that --stack wasn't supplied if ctx.parent.obj.stack: @@ -109,20 +111,13 @@ def command(ctx): @command.command() @click.option("--kube-config", help="Provide a config file for a k8s deployment") -@click.option( - "--image-registry", - help="Provide a container image registry url for this k8s cluster", -) -@click.option( - "--deployment-dir", help="Create deployment files in this directory", required=True -) +@click.option("--image-registry", help="Provide a container image registry url for this k8s cluster") +@click.option("--deployment-dir", help="Create deployment files in this directory", required=True) @click.option("--image", help="image to deploy", required=True) @click.option("--url", help="url to serve", required=True) @click.option("--env-file", help="environment file for webapp") @click.pass_context def create(ctx, deployment_dir, image, url, kube_config, image_registry, env_file): - """create a deployment for the specified webapp container""" + '''create a deployment for the specified webapp container''' - return create_deployment( - ctx, deployment_dir, image, url, kube_config, image_registry, env_file - ) + return create_deployment(ctx, deployment_dir, image, url, kube_config, image_registry, env_file)