@@ -253,11 +253,16 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
253253 return codersdk.WorkspaceAgentListContainersResponse {}, xerrors .Errorf ("scan docker ps output: %w" , err )
254254 }
255255
256+ res := codersdk.WorkspaceAgentListContainersResponse {
257+ Containers : make ([]codersdk.WorkspaceAgentDevcontainer , 0 , len (ids )),
258+ Warnings : make ([]string , 0 ),
259+ }
256260 dockerPsStderr := strings .TrimSpace (stderrBuf .String ())
261+ if dockerPsStderr != "" {
262+ res .Warnings = append (res .Warnings , dockerPsStderr )
263+ }
257264 if len (ids ) == 0 {
258- return codersdk.WorkspaceAgentListContainersResponse {
259- Warnings : []string {dockerPsStderr },
260- }, nil
265+ return res , nil
261266 }
262267
263268 // now we can get the detailed information for each container
@@ -273,13 +278,10 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
273278 return codersdk.WorkspaceAgentListContainersResponse {}, xerrors .Errorf ("run docker inspect: %w" , err )
274279 }
275280
276- res := codersdk.WorkspaceAgentListContainersResponse {
277- Containers : make ([]codersdk.WorkspaceAgentDevcontainer , len (ins )),
278- }
279- for idx , in := range ins {
281+ for _ , in := range ins {
280282 out , warns := convertDockerInspect (in )
281283 res .Warnings = append (res .Warnings , warns ... )
282- res .Containers [ idx ] = out
284+ res .Containers = append ( res . Containers , out )
283285 }
284286
285287 if dockerPsStderr != "" {
0 commit comments