Skip to content

Commit 8a31b4f

Browse files
committed
Skip non-dev container instances
1 parent 3c13d0f commit 8a31b4f

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

internal/pkg/devcontainers/dockerutils.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ func ListDevcontainers() ([]DevcontainerInfo, error) {
5959
for scanner.Scan() {
6060
line := scanner.Text()
6161
parts := strings.Split(line, "|")
62+
localPath := parts[listPartLocalFolder]
63+
if localPath == "" {
64+
// not a dev container
65+
continue
66+
}
67+
if wsl.HasWslPathPrefix(localPath) && wsl.IsWsl() {
68+
localPath, err = wsl.ConvertWindowsPathToWslPath(localPath)
69+
if err != nil {
70+
return []DevcontainerInfo{}, fmt.Errorf("error converting path: %s", err)
71+
}
72+
}
6273
name := parts[listPartLocalFolder]
6374
if name == "" {
6475
// No local folder => use dockercompose parts
@@ -69,13 +80,6 @@ func ListDevcontainers() ([]DevcontainerInfo, error) {
6980
name = name[index+1:]
7081
}
7182
}
72-
localPath := parts[listPartLocalFolder]
73-
if wsl.HasWslPathPrefix(localPath) && wsl.IsWsl() {
74-
localPath, err = wsl.ConvertWindowsPathToWslPath(localPath)
75-
if err != nil {
76-
return []DevcontainerInfo{}, fmt.Errorf("error converting path: %s", err)
77-
}
78-
}
7983
devcontainer := DevcontainerInfo{
8084
ContainerID: parts[listPartID],
8185
ContainerName: parts[listPartContainerName],

0 commit comments

Comments
 (0)