Skip to content

Commit ef6c2de

Browse files
committed
fix: rename variable for clarity and validate app descriptor in HandleAppStart
1 parent 7878a2c commit ef6c2de

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/api/handlers/app_start.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func HandleAppStart(
4747
return
4848
}
4949

50-
app, err := app.Load(id.ToPath().String())
50+
appLoaded, err := app.Load(id.ToPath().String())
5151
if err != nil {
5252
slog.Error("Unable to parse the app.yaml", slog.String("error", err.Error()), slog.String("path", id.String()))
5353
render.EncodeResponse(w, http.StatusInternalServerError, models.ErrorResponse{Details: "unable to find the app"})
@@ -62,14 +62,22 @@ func HandleAppStart(
6262
}
6363
defer sseStream.Close()
6464

65+
err = app.ValidateBricks(appLoaded.Descriptor, bricksIndex)
66+
if err != nil {
67+
sseStream.SendError(render.SSEErrorData{
68+
Code: render.InternalServiceErr,
69+
Message: err.Error(),
70+
})
71+
}
72+
6573
type progress struct {
6674
Name string `json:"name"`
6775
Progress float32 `json:"progress"`
6876
}
6977
type log struct {
7078
Message string `json:"message"`
7179
}
72-
for item := range orchestrator.StartApp(r.Context(), dockerCli, provisioner, modelsIndex, bricksIndex, app, cfg, staticStore) {
80+
for item := range orchestrator.StartApp(r.Context(), dockerCli, provisioner, modelsIndex, bricksIndex, appLoaded, cfg, staticStore) {
7381
switch item.GetType() {
7482
case orchestrator.ProgressType:
7583
sseStream.Send(render.SSEEvent{Type: "progress", Data: progress(*item.GetProgress())})

0 commit comments

Comments
 (0)