Skip to content

Commit 8c3cf79

Browse files
authored
Merge pull request #42 from fastapilabs/04-29-_add_deployment_url_on_complete
✨ Add deployment url on complete
2 parents f2780d3 + 56c37a1 commit 8c3cf79

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

src/fastapi_cloud_cli/commands/deploy.py

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

130131

131132
def _create_deployment(app_id: str) -> CreateDeploymentResponse:
@@ -190,24 +191,6 @@ def _get_apps(team_id: str) -> List[AppResponse]:
190191
return [AppResponse.model_validate(app) for app in data]
191192

192193

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-
211194
def _create_environment_variables(app_id: str, env_vars: Dict[str, str]) -> None:
212195
with APIClient() as client:
213196
response = client.patch(f"/apps/{app_id}/environment-variables/", json=env_vars)
@@ -315,7 +298,7 @@ def _configure_app(toolkit: RichToolkit, path_to_deploy: Path) -> AppConfig:
315298

316299

317300
def _wait_for_deployment(
318-
toolkit: RichToolkit, app_id: str, deployment_id: str, check_deployment_url: str
301+
toolkit: RichToolkit, app_id: str, deployment: CreateDeploymentResponse
319302
) -> None:
320303
messages = cycle(WAITING_MESSAGES)
321304

@@ -326,7 +309,7 @@ def _wait_for_deployment(
326309
toolkit.print_line()
327310

328311
toolkit.print(
329-
f"You can also check the status at [link={check_deployment_url}]{check_deployment_url}[/link]",
312+
f"You can also check the status at [link={deployment.dashboard_url}]{deployment.dashboard_url}[/link]",
330313
)
331314
toolkit.print_line()
332315

@@ -339,14 +322,21 @@ def _wait_for_deployment(
339322
with toolkit.progress(
340323
next(messages), inline_logs=True, lines_to_show=20
341324
) as progress:
342-
for line in _stream_build_logs(deployment_id):
325+
for line in _stream_build_logs(deployment.id):
343326
time_elapsed = time.monotonic() - started_at
344327

345328
data = json.loads(line)
346329

347330
if "message" in data:
348331
progress.log(Text.from_ansi(data["message"].rstrip()))
349332

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

@@ -465,11 +455,9 @@ def deploy(
465455

466456
toolkit.print_line()
467457

468-
check_deployment_url = deployment.dashboard_url
469-
470458
if not skip_wait:
471-
_wait_for_deployment(toolkit, app.id, deployment.id, check_deployment_url)
459+
_wait_for_deployment(toolkit, app.id, deployment=deployment)
472460
else:
473461
toolkit.print(
474-
f"Check the status of your deployment at [link={check_deployment_url}]{check_deployment_url}[/link]"
462+
f"Check the status of your deployment at [link={deployment.dashboard_url}]{deployment.dashboard_url}[/link]"
475463
)

0 commit comments

Comments
 (0)