Skip to content

Commit

Permalink
open terminal bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamcatcher45 committed Nov 23, 2024
1 parent 60a066c commit 5b0f686
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [2.0.3] - 2024-11-23
### Added
- Open in terminal bug fix for containers

## [0.1.9] - 2024-10-20
### Added
- Added create volume tool
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "podmanager",
"displayName": "Pod Manager",
"description": "Manage Podman containers, images, volumes, and networks.",
"version": "2.0.2",
"version": "2.0.3",
"publisher": "dreamcatcher45",
"homepage": "https://pod-manager.pages.dev",
"repository": {
Expand Down
13 changes: 12 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ async function restartContainer(item: PodmanItem) {
async function openInTerminal(item: PodmanItem) {
if (item.id) {
try {
const containerId = extractContainerId(item.id);
const terminal = vscode.window.createTerminal(`Podman: ${item.label}`);
terminal.sendText(`${getPodmanPath()} exec -it ${item.id} /bin/sh`);
terminal.sendText(`${getPodmanPath()} exec -it ${containerId} /bin/sh`);
terminal.show();
} catch (error) {
vscode.window.showErrorMessage(`Failed to open terminal for container ${item.id}: ${error}`);
Expand Down Expand Up @@ -277,6 +278,16 @@ async function deleteNetwork(item: PodmanItem) {
}
}

function extractContainerId(fullId: string): string {
// If the ID contains a hyphen followed by a hash-like string at the end
const match = fullId.match(/-([a-f0-9]{12})$/i);
if (match) {
return match[1];
}
// If no match found, return the original ID
return fullId;
}

async function checkPodmanMachineStatus(): Promise<boolean> {
try {
const { stdout } = await execAsync(`${getPodmanPath()} machine list --format "{{.Name}}|{{.Running}}"`);
Expand Down

0 comments on commit 5b0f686

Please sign in to comment.