From d247571720bd5419591051736e0b4c4e3705395c Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Tue, 29 Oct 2024 10:37:01 -0400 Subject: [PATCH] remove `deleteContainer`, add `restartContainer` --- src/docker/containers.ts | 20 +++----------------- src/docker/workflows/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/docker/containers.ts b/src/docker/containers.ts index c95c5358..20e05262 100644 --- a/src/docker/containers.ts +++ b/src/docker/containers.ts @@ -134,21 +134,7 @@ export async function stopContainer(id: string) { } } -export async function deleteContainer(id: string) { - const client = new ContainerApi(); - const init: RequestInit = defaultRequestInit(); - - try { - await client.containerDelete({ id }, init); - } catch (error) { - if (error instanceof ResponseError) { - logger.error("Error response deleting container:", { - status: error.response.status, - statusText: error.response.statusText, - body: await error.response.clone().json(), - }); - } else { - logger.error("Error removing container:", error); - } - } +export async function restartContainer(id: string) { + await stopContainer(id); + await startContainer(id); } diff --git a/src/docker/workflows/index.ts b/src/docker/workflows/index.ts index 9af2ca67..aea9cabb 100644 --- a/src/docker/workflows/index.ts +++ b/src/docker/workflows/index.ts @@ -2,7 +2,7 @@ import net from "net"; import { CancellationToken, commands, Progress, window } from "vscode"; import { ContainerSummary } from "../../clients/docker"; import { Logger } from "../../logging"; -import { startContainer } from "../containers"; +import { restartContainer, startContainer } from "../containers"; import { imageExists, pullImage } from "../images"; /** Basic container information for a local resource. */ @@ -122,7 +122,7 @@ export abstract class LocalResourceWorkflow { return; } if (anyRunning) { - // TODO: implement stop+start in downstream branch + promises.push(restartContainer(container.Id)); } else { promises.push(startContainer(container.Id)); }