Skip to content

Commit

Permalink
remove deleteContainer, add restartContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
shouples committed Oct 30, 2024
1 parent f0d4d01 commit d247571
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
20 changes: 3 additions & 17 deletions src/docker/containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions src/docker/workflows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit d247571

Please sign in to comment.