@@ -310,24 +310,20 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
310
310
// runDockerInspect is a helper function that runs `docker inspect` on the given
311
311
// container IDs and returns the parsed output.
312
312
// The stderr output is also returned for logging purposes.
313
- func runDockerInspect (ctx context.Context , execer agentexec.Execer , ids ... string ) (stdout , stderr []byte , retErr error ) {
313
+ func runDockerInspect (ctx context.Context , execer agentexec.Execer , ids ... string ) (stdout , stderr []byte , err error ) {
314
314
var stdoutBuf , stderrBuf bytes.Buffer
315
315
cmd := execer .CommandContext (ctx , "docker" , append ([]string {"inspect" }, ids ... )... )
316
316
cmd .Stdout = & stdoutBuf
317
317
cmd .Stderr = & stderrBuf
318
- err : = cmd .Run ()
318
+ err = cmd .Run ()
319
319
stdout = bytes .TrimSpace (stdoutBuf .Bytes ())
320
320
stderr = bytes .TrimSpace (stderrBuf .Bytes ())
321
- if err != nil {
322
- if bytes .Contains (stderr , []byte ("No such object:" )) {
323
- // This can happen if a container is deleted between the time we check for its existence and the time we inspect it.
324
- retErr = nil
325
- } else {
326
- retErr = err
327
- }
321
+ if err != nil && bytes .Contains (stderr , []byte ("No such object:" )) {
322
+ // This can happen if a container is deleted between the time we check for its existence and the time we inspect it.
323
+ return stdout , stderr , nil
328
324
}
329
325
330
- return stdout , stderr , retErr
326
+ return stdout , stderr , err
331
327
}
332
328
333
329
// To avoid a direct dependency on the Docker API, we use the docker CLI
0 commit comments