@@ -253,11 +253,16 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
253
253
return codersdk.WorkspaceAgentListContainersResponse {}, xerrors .Errorf ("scan docker ps output: %w" , err )
254
254
}
255
255
256
+ res := codersdk.WorkspaceAgentListContainersResponse {
257
+ Containers : make ([]codersdk.WorkspaceAgentDevcontainer , 0 , len (ids )),
258
+ Warnings : make ([]string , 0 ),
259
+ }
256
260
dockerPsStderr := strings .TrimSpace (stderrBuf .String ())
261
+ if dockerPsStderr != "" {
262
+ res .Warnings = append (res .Warnings , dockerPsStderr )
263
+ }
257
264
if len (ids ) == 0 {
258
- return codersdk.WorkspaceAgentListContainersResponse {
259
- Warnings : []string {dockerPsStderr },
260
- }, nil
265
+ return res , nil
261
266
}
262
267
263
268
// now we can get the detailed information for each container
@@ -273,13 +278,10 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
273
278
return codersdk.WorkspaceAgentListContainersResponse {}, xerrors .Errorf ("run docker inspect: %w" , err )
274
279
}
275
280
276
- res := codersdk.WorkspaceAgentListContainersResponse {
277
- Containers : make ([]codersdk.WorkspaceAgentDevcontainer , len (ins )),
278
- }
279
- for idx , in := range ins {
281
+ for _ , in := range ins {
280
282
out , warns := convertDockerInspect (in )
281
283
res .Warnings = append (res .Warnings , warns ... )
282
- res .Containers [ idx ] = out
284
+ res .Containers = append ( res . Containers , out )
283
285
}
284
286
285
287
if dockerPsStderr != "" {
0 commit comments