Parse url parameter

This commit is contained in:
David Boreham 2023-11-27 21:59:38 -07:00
parent 4e94b360a6
commit 2fa1785ce8

View File

@ -15,6 +15,7 @@
import click import click
from pathlib import Path from pathlib import Path
from urllib.parse import urlparse
from stack_orchestrator.util import error_exit, global_options2 from stack_orchestrator.util import error_exit, global_options2
from stack_orchestrator.deploy.deployment_create import init_operation, create_operation from stack_orchestrator.deploy.deployment_create import init_operation, create_operation
@ -33,12 +34,14 @@ def _fixup_container_tag(deployment_dir: str, image: str):
wfile.write(contents) wfile.write(contents)
def _fixup_url_spec(spec_file_name: str): def _fixup_url_spec(spec_file_name: str, url: str):
http_proxy_spec = ''' # url is like: https://example.com/path
parsed_url = urlparse(url)
http_proxy_spec = f'''
http-proxy: http-proxy:
- host-name: test-app.laconic.servesthe.world - host-name: {parsed_url.hostname}
routes: routes:
- path: '/' - path: '{parsed_url.path if parsed_url.path else "/"}'
proxy-to: webapp:3000 proxy-to: webapp:3000
''' '''
spec_file_path = Path(spec_file_name) spec_file_path = Path(spec_file_name)
@ -98,7 +101,7 @@ def create(ctx, deployment_dir, image, url, kube_config, image_registry, env_fil
None None
) )
# Add the TLS and DNS spec # Add the TLS and DNS spec
_fixup_url_spec(spec_file_name) _fixup_url_spec(spec_file_name, url)
create_operation( create_operation(
deploy_command_context, deploy_command_context,
spec_file_name, spec_file_name,