Skip to content

Commit f17e499

Browse files
committed
add unitialized status, add status in app lists
1 parent 9da6e0b commit f17e499

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

internal/orchestrator/helpers.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,23 +163,17 @@ func getAppStatusByPath(
163163
return &app[0], nil
164164
}
165165

166-
// TODO: merge this with the more efficient getAppStatusByPath
167166
func getAppStatus(
168167
ctx context.Context,
169168
docker command.Cli,
170169
app app.ArduinoApp,
171170
) (AppStatusInfo, error) {
172-
apps, err := getAppsStatus(ctx, docker.Client())
171+
statusInfo, err := getAppStatusByPath(ctx, docker.Client(), app.FullPath.String())
172+
173173
if err != nil {
174174
return AppStatusInfo{}, fmt.Errorf("failed to get app status: %w", err)
175175
}
176-
idx := slices.IndexFunc(apps, func(a AppStatusInfo) bool {
177-
return a.AppPath.String() == app.FullPath.String()
178-
})
179-
if idx == -1 {
180-
return AppStatusInfo{}, fmt.Errorf("app %s not found", app.FullPath)
181-
}
182-
return apps[idx], nil
176+
return *statusInfo, nil
183177
}
184178

185179
func getRunningApp(

internal/orchestrator/orchestrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ func ListApps(
713713
continue
714714
}
715715

716-
var status Status
716+
status := StatusUninitialized
717717
if idx := slices.IndexFunc(apps, func(a AppStatusInfo) bool {
718718
return a.AppPath.EqualsTo(app.FullPath)
719719
}); idx != -1 {

internal/orchestrator/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ func ParseStatus(s string) (Status, error) {
5656

5757
func (s Status) Validate() error {
5858
switch s {
59-
case StatusStarting, StatusRunning, StatusStopping, StatusStopped, StatusFailed:
59+
case StatusStarting, StatusRunning, StatusStopping, StatusStopped, StatusFailed, StatusUninitialized:
6060
return nil
6161
default:
6262
return fmt.Errorf("status should be one of %v", s.AllowedStatuses())
6363
}
6464
}
6565

6666
func (s Status) AllowedStatuses() []Status {
67-
return []Status{StatusStarting, StatusRunning, StatusStopping, StatusStopped, StatusFailed}
67+
return []Status{StatusStarting, StatusRunning, StatusStopping, StatusStopped, StatusFailed, StatusUninitialized}
6868
}

0 commit comments

Comments
 (0)