Set auction id in deployment request

This commit is contained in:
Prathamesh Musale 2024-09-30 12:22:04 +05:30
parent 61e1116e33
commit b84527d9c6
2 changed files with 14 additions and 7 deletions

View File

@ -20,12 +20,11 @@ import click
import yaml import yaml
from stack_orchestrator.deploy.webapp.util import ( from stack_orchestrator.deploy.webapp.util import (
AUCTION_KIND_PROVIDER,
TOKEN_DENOM,
LaconicRegistryClient, LaconicRegistryClient,
) )
AUCTION_KIND_PROVIDER = "provider"
TOKEN_DENOM = "alnt"
def fatal(msg: str): def fatal(msg: str):
print(msg, file=sys.stderr) print(msg, file=sys.stderr)
sys.exit(1) sys.exit(1)

View File

@ -136,9 +136,10 @@ def command(
if not deployer_record: if not deployer_record:
fatal(f"Unable to locate deployer: {deployer}") fatal(f"Unable to locate deployer: {deployer}")
deployer_records.append(deployer_records_by_owner[0]) deployer_records.append(deployer_record)
# Create and send request to each deployer # Create and send request to each deployer
deployment_requests = []
for deployer_record in deployer_records: for deployer_record in deployer_records:
# If env_file # If env_file
if env_file: if env_file:
@ -183,11 +184,15 @@ def command(
"application": app, "application": app,
"version": "1.0.0", "version": "1.0.0",
"name": f"{app_record.attributes.name}@{app_record.attributes.version}", "name": f"{app_record.attributes.name}@{app_record.attributes.version}",
"deployer": deployer,
"meta": {"when": str(datetime.utcnow())}, "meta": {"when": str(datetime.utcnow())},
} }
} }
if auction_id:
deployment_request["record"]["auction"] = auction_id
else:
deployment_request["record"]["deployer"] = deployer
if config_ref: if config_ref:
deployment_request["record"]["config"] = {"ref": config_ref} deployment_request["record"]["config"] = {"ref": config_ref}
@ -214,11 +219,14 @@ def command(
elif use_payment: elif use_payment:
deployment_request["record"]["payment"] = use_payment deployment_request["record"]["payment"] = use_payment
deployment_requests.append(deployment_request)
# Send all requests
for deployment_request in deployment_requests:
if dry_run: if dry_run:
print(yaml.dump(deployment_request)) print(yaml.dump(deployment_request))
return continue
# Send the request
laconic.publish(deployment_request) laconic.publish(deployment_request)
finally: finally:
shutil.rmtree(tempdir, ignore_errors=True) shutil.rmtree(tempdir, ignore_errors=True)