Skip to content

Commit 8fd324e

Browse files
authored
Add REMOTE_CONTAINERS_IPC, VSCODE_GIT_IPC_HANDLE (#71)
* Add REMOTE_CONTAINERS_IPC, VSCODE_GIT_IPC_HANDLE * Update devcontainers/ci version
1 parent 1f149e7 commit 8fd324e

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

.github/workflows/build-and-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
mkdir -p ~/.azure
3636
3737
- name: Build and run CLI
38-
uses: devcontainers/ci@v0.2
38+
uses: devcontainers/ci@v0.3
3939
env:
4040
GITHUB_TOKEN: ${{ secrets.GH_CROSS_REPO_TOKEN }}
4141
BUILD_NUMBER: ${{ github.run_id }}

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ go 1.14
55
require (
66
github.com/blang/semver v3.5.1+incompatible
77
github.com/bradford-hamilton/dora v0.1.1
8-
github.com/kyoh86/richgo v0.3.10 // indirect
9-
github.com/mattn/go-isatty v0.0.16 // indirect
8+
github.com/kyoh86/richgo v0.3.12 // indirect
109
github.com/rhysd/go-github-selfupdate v1.2.2
1110
github.com/spf13/cobra v1.0.0
1211
github.com/spf13/viper v1.4.0
13-
github.com/stretchr/testify v1.7.0
14-
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
12+
github.com/stretchr/testify v1.8.2
13+
golang.org/x/sys v0.6.0 // indirect
1514
gopkg.in/yaml.v2 v2.4.0 // indirect
1615
)
1716

go.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
6969
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
7070
github.com/kyoh86/richgo v0.3.10 h1:iSGvcjhtQN2IVrBDhPk0if0R/RMQnCN1E/9OyAW4UUs=
7171
github.com/kyoh86/richgo v0.3.10/go.mod h1:2Odx7Qx2iJxXEWmoXVWaNbUcBXhHY43qSgyK7dbTaII=
72+
github.com/kyoh86/richgo v0.3.12 h1:W66IRaaC1BWoCPIyI94t/PChWBQ38QFDRsF1nWu4904=
73+
github.com/kyoh86/richgo v0.3.12/go.mod h1:op8jQyhnxSZQelHDyupswwJGerEDB6zkKfzCnuqAwx4=
7274
github.com/kyoh86/xdg v1.2.0 h1:CERuT/ShdTDj+A2UaX3hQ3mOV369+Sj+wyn2nIRIIkI=
7375
github.com/kyoh86/xdg v1.2.0/go.mod h1:/mg8zwu1+qe76oTFUBnyS7rJzk7LLC0VGEzJyJ19DHs=
7476
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
7577
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
7678
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
7779
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
7880
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
81+
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
82+
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
7983
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
8084
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
8185
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
@@ -125,10 +129,16 @@ github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
125129
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
126130
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
127131
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
132+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
133+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
128134
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
129135
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
130136
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
131137
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
138+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
139+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
140+
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
141+
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
132142
github.com/stuartleeks/dora v0.1.5 h1:/t8/kPA2t1qMUI9W0cASGGScpgyNDQ5O+QOYud8+AlQ=
133143
github.com/stuartleeks/dora v0.1.5/go.mod h1:Xu0GCcuQv5e9Ta0U3PUiu/rgaXJnHn1+LTaQkCgYMhc=
134144
github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw=
@@ -177,6 +187,9 @@ golang.org/x/sys v0.0.0-20220926163933-8cfa568d3c25 h1:nwzwVf0l2Y/lkov/+IYgMMbFy
177187
golang.org/x/sys v0.0.0-20220926163933-8cfa568d3c25/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
178188
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
179189
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
190+
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
191+
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
192+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
180193
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
181194
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
182195
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -205,4 +218,6 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
205218
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
206219
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
207220
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
221+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
222+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
208223
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

internal/pkg/devcontainers/dockerutils.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,27 @@ func ExecInDevContainer(containerID string, workDir string, args []string) error
271271
fmt.Println("Continuing without overriding PATH...")
272272
}
273273

274-
statusWriter.Printf("Getting code IPC SOCK")
275-
ipcSock, err := getVscodeIpcSock(containerID)
274+
statusWriter.Printf("Getting VSCODE_IPC_HOOK_CLI")
275+
vscodeIpcSock, err := getVscodeIpcSock(containerID)
276276
if err != nil {
277-
ipcSock = ""
278-
fmt.Printf("Warning; Failed to get VS Code IPC SOCK: %s\n", err)
277+
vscodeIpcSock = ""
278+
fmt.Printf("Warning; Failed to get VSCODE_IPC_HOOK_CLI: %s\n", err)
279279
fmt.Println("Continuing without setting VSCODE_IPC_HOOK_CLI...")
280280
}
281+
statusWriter.Printf("Getting REMOTE_CONTAINERS_IPC")
282+
remoteContainersIpcSock, err := getRemoteContainersIpcSock(containerID)
283+
if err != nil {
284+
remoteContainersIpcSock = ""
285+
fmt.Printf("Warning; Failed to get REMOTE_CONTAINERS_IPC: %s\n", err)
286+
fmt.Println("Continuing without setting REMOTE_CONTAINERS_IPC...")
287+
}
288+
statusWriter.Printf("Getting VSCODE_GIT_IPC_HANDLE")
289+
vscodeGitIpcSock, err := getGitIpcSock(containerID)
290+
if err != nil {
291+
vscodeGitIpcSock = ""
292+
fmt.Printf("Warning; Failed to get VSCODE_GIT_IPC_HANDLE: %s\n", err)
293+
fmt.Println("Continuing without setting VSCODE_GIT_IPC_HANDLE...")
294+
}
281295

282296
mountPath := sourceInfo.DockerMount.Destination
283297
if workDir == "" {
@@ -319,8 +333,14 @@ func ExecInDevContainer(containerID string, workDir string, args []string) error
319333
if containerPath != "" {
320334
dockerArgs = append(dockerArgs, "--env", "PATH="+containerPath)
321335
}
322-
if ipcSock != "" {
323-
dockerArgs = append(dockerArgs, "--env", "VSCODE_IPC_HOOK_CLI="+ipcSock)
336+
if vscodeIpcSock != "" {
337+
dockerArgs = append(dockerArgs, "--env", "VSCODE_IPC_HOOK_CLI="+vscodeIpcSock)
338+
}
339+
if remoteContainersIpcSock != "" {
340+
dockerArgs = append(dockerArgs, "--env", "REMOTE_CONTAINERS_IPC="+remoteContainersIpcSock)
341+
}
342+
if vscodeGitIpcSock != "" {
343+
dockerArgs = append(dockerArgs, "--env", "VSCODE_GIT_IPC_HANDLE="+vscodeGitIpcSock)
324344
}
325345
dockerArgs = append(dockerArgs, containerID)
326346
dockerArgs = append(dockerArgs, args...)
@@ -372,6 +392,12 @@ func getVscodeServerPath(containerID string) (string, error) {
372392
func getVscodeIpcSock(containerID string) (string, error) {
373393
return getLatestFileMatch(containerID, "\"${TMPDIR:-/tmp}\"/vscode-ipc-*")
374394
}
395+
func getRemoteContainersIpcSock(containerID string) (string, error) {
396+
return getLatestFileMatch(containerID, "\"${TMPDIR:-/tmp}\"/vscode-remote-containers-ipc-*")
397+
}
398+
func getGitIpcSock(containerID string) (string, error) {
399+
return getLatestFileMatch(containerID, "\"${TMPDIR:-/tmp}\"/vscode-git-*")
400+
}
375401

376402
// getLatestFileMatch lists files matching `pattern` in the container and returns the latest filename
377403
func getLatestFileMatch(containerID string, pattern string) (string, error) {

0 commit comments

Comments
 (0)