Skip to content

Commit 1adc42d

Browse files
committed
✨ Add deployment url on complete
1 parent f2780d3 commit 1adc42d

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

src/fastapi_cloud_cli/commands/deploy.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class CreateDeploymentResponse(BaseModel):
126126
slug: str
127127
status: DeploymentStatus
128128
dashboard_url: str
129-
129+
url: str
130130

131131
def _create_deployment(app_id: str) -> CreateDeploymentResponse:
132132
with APIClient() as client:
@@ -190,24 +190,6 @@ def _get_apps(team_id: str) -> List[AppResponse]:
190190
return [AppResponse.model_validate(app) for app in data]
191191

192192

193-
class DeploymentResponse(BaseModel):
194-
id: str
195-
app_id: str
196-
slug: str
197-
status: DeploymentStatus
198-
url: str
199-
200-
201-
def _get_deployment(app_id: str, deployment_id: str) -> DeploymentResponse:
202-
with APIClient() as client:
203-
response = client.get(f"/apps/{app_id}/deployments/{deployment_id}")
204-
response.raise_for_status()
205-
206-
data = response.json()
207-
208-
return DeploymentResponse.model_validate(data)
209-
210-
211193
def _create_environment_variables(app_id: str, env_vars: Dict[str, str]) -> None:
212194
with APIClient() as client:
213195
response = client.patch(f"/apps/{app_id}/environment-variables/", json=env_vars)
@@ -315,7 +297,7 @@ def _configure_app(toolkit: RichToolkit, path_to_deploy: Path) -> AppConfig:
315297

316298

317299
def _wait_for_deployment(
318-
toolkit: RichToolkit, app_id: str, deployment_id: str, check_deployment_url: str
300+
toolkit: RichToolkit, app_id: str, deployment: CreateDeploymentResponse
319301
) -> None:
320302
messages = cycle(WAITING_MESSAGES)
321303

@@ -326,7 +308,7 @@ def _wait_for_deployment(
326308
toolkit.print_line()
327309

328310
toolkit.print(
329-
f"You can also check the status at [link={check_deployment_url}]{check_deployment_url}[/link]",
311+
f"You can also check the status at [link={deployment.dashboard_url}]{deployment.dashboard_url}[/link]",
330312
)
331313
toolkit.print_line()
332314

@@ -339,14 +321,21 @@ def _wait_for_deployment(
339321
with toolkit.progress(
340322
next(messages), inline_logs=True, lines_to_show=20
341323
) as progress:
342-
for line in _stream_build_logs(deployment_id):
324+
for line in _stream_build_logs(deployment.id):
343325
time_elapsed = time.monotonic() - started_at
344326

345327
data = json.loads(line)
346328

347329
if "message" in data:
348330
progress.log(Text.from_ansi(data["message"].rstrip()))
349331

332+
if data.get("type") == "complete":
333+
progress.log("")
334+
progress.log(
335+
f"🐔 Ready the chicken! Your app is ready at [link={deployment.url}]{deployment.url}[/link]"
336+
)
337+
break
338+
350339
if time_elapsed > 10:
351340
messages = cycle(LONG_WAIT_MESSAGES)
352341

@@ -465,11 +454,9 @@ def deploy(
465454

466455
toolkit.print_line()
467456

468-
check_deployment_url = deployment.dashboard_url
469-
470457
if not skip_wait:
471-
_wait_for_deployment(toolkit, app.id, deployment.id, check_deployment_url)
458+
_wait_for_deployment(toolkit, app.id, deployment=deployment)
472459
else:
473460
toolkit.print(
474-
f"Check the status of your deployment at [link={check_deployment_url}]{check_deployment_url}[/link]"
461+
f"Check the status of your deployment at [link={deployment.dashboard_url}]{deployment.dashboard_url}[/link]"
475462
)

0 commit comments

Comments
 (0)