forked from cerc-io/stack-orchestrator
Configure spec with all given URLs
This commit is contained in:
parent
f5947a8a65
commit
3d1a455344
@ -36,25 +36,29 @@ def _fixup_container_tag(deployment_dir: str, image: str):
|
||||
wfile.write(contents)
|
||||
|
||||
|
||||
def _fixup_url_spec(spec_file_name: str, url: str):
|
||||
# url is like: https://example.com/path
|
||||
def _fixup_url_spec(spec_file_name: str, urls: list[str]):
|
||||
http_proxy_entries = []
|
||||
for url in urls:
|
||||
parsed_url = urlparse(url)
|
||||
http_proxy_spec = f'''
|
||||
http-proxy:
|
||||
http_proxy_entries.append(f'''
|
||||
- host-name: {parsed_url.hostname}
|
||||
routes:
|
||||
- path: '{parsed_url.path if parsed_url.path else "/"}'
|
||||
proxy-to: webapp:80
|
||||
proxy-to: webapp:80''')
|
||||
|
||||
http_proxy_spec = f'''
|
||||
http-proxy:{''.join(http_proxy_entries)}
|
||||
'''
|
||||
|
||||
spec_file_path = Path(spec_file_name)
|
||||
with open(spec_file_path) as rfile:
|
||||
with open(spec_file_path, "r") as rfile:
|
||||
contents = rfile.read()
|
||||
contents = contents + http_proxy_spec
|
||||
contents += http_proxy_spec
|
||||
with open(spec_file_path, "w") as wfile:
|
||||
wfile.write(contents)
|
||||
|
||||
|
||||
def create_deployment(ctx, deployment_dir, image, url, kube_config, image_registry, env_file):
|
||||
def create_deployment(ctx, deployment_dir, image, urls, 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)
|
||||
@ -86,7 +90,7 @@ def create_deployment(ctx, deployment_dir, image, url, kube_config, image_regist
|
||||
None
|
||||
)
|
||||
# Add the TLS and DNS spec
|
||||
_fixup_url_spec(spec_file_name, url)
|
||||
_fixup_url_spec(spec_file_name, urls)
|
||||
create_operation(
|
||||
deploy_command_context,
|
||||
spec_file_name,
|
||||
@ -120,4 +124,4 @@ def command(ctx):
|
||||
def create(ctx, deployment_dir, image, url, kube_config, image_registry, env_file):
|
||||
'''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)
|
||||
|
@ -189,12 +189,11 @@ def process_app_deployment_request(
|
||||
logger.log(
|
||||
f"Creating webapp deployment in: {deployment_dir} with container id: {deployment_container_tag}"
|
||||
)
|
||||
# TODO: Pass URLs for all fqdns
|
||||
deploy_webapp.create_deployment(
|
||||
ctx,
|
||||
deployment_dir,
|
||||
deployment_container_tag,
|
||||
f"https://{fqdns[-1]}",
|
||||
[f"https://{fqdn}" for fqdn in fqdns],
|
||||
kube_config,
|
||||
image_registry,
|
||||
env_filename,
|
||||
@ -649,7 +648,6 @@ def command( # noqa: C901
|
||||
requests_to_check_for_payment.append(r)
|
||||
|
||||
requests_to_execute = []
|
||||
# TODO: Charge more for multiple dns?
|
||||
for r in requests_to_check_for_payment:
|
||||
if r.attributes.auction:
|
||||
if auction_requests:
|
||||
|
Loading…
Reference in New Issue
Block a user