diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 69546dc..34a587d 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -35,7 +35,7 @@ jobs: mkdir -p ~/.azure - name: Build and run CLI - uses: devcontainers/ci@v0.2 + uses: devcontainers/ci@v0.3 env: GITHUB_TOKEN: ${{ secrets.GH_CROSS_REPO_TOKEN }} BUILD_NUMBER: ${{ github.run_id }} diff --git a/go.mod b/go.mod index 49456e4..4f6dcf6 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,12 @@ go 1.14 require ( github.com/blang/semver v3.5.1+incompatible github.com/bradford-hamilton/dora v0.1.1 - github.com/kyoh86/richgo v0.3.10 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/kyoh86/richgo v0.3.12 // indirect github.com/rhysd/go-github-selfupdate v1.2.2 github.com/spf13/cobra v1.0.0 github.com/spf13/viper v1.4.0 - github.com/stretchr/testify v1.7.0 - golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect + github.com/stretchr/testify v1.8.2 + golang.org/x/sys v0.6.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 1e68252..cecd6e8 100644 --- a/go.sum +++ b/go.sum @@ -69,6 +69,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kyoh86/richgo v0.3.10 h1:iSGvcjhtQN2IVrBDhPk0if0R/RMQnCN1E/9OyAW4UUs= github.com/kyoh86/richgo v0.3.10/go.mod h1:2Odx7Qx2iJxXEWmoXVWaNbUcBXhHY43qSgyK7dbTaII= +github.com/kyoh86/richgo v0.3.12 h1:W66IRaaC1BWoCPIyI94t/PChWBQ38QFDRsF1nWu4904= +github.com/kyoh86/richgo v0.3.12/go.mod h1:op8jQyhnxSZQelHDyupswwJGerEDB6zkKfzCnuqAwx4= github.com/kyoh86/xdg v1.2.0 h1:CERuT/ShdTDj+A2UaX3hQ3mOV369+Sj+wyn2nIRIIkI= github.com/kyoh86/xdg v1.2.0/go.mod h1:/mg8zwu1+qe76oTFUBnyS7rJzk7LLC0VGEzJyJ19DHs= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= @@ -76,6 +78,8 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= @@ -125,10 +129,16 @@ github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stuartleeks/dora v0.1.5 h1:/t8/kPA2t1qMUI9W0cASGGScpgyNDQ5O+QOYud8+AlQ= github.com/stuartleeks/dora v0.1.5/go.mod h1:Xu0GCcuQv5e9Ta0U3PUiu/rgaXJnHn1+LTaQkCgYMhc= 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 golang.org/x/sys v0.0.0-20220926163933-8cfa568d3c25/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/pkg/devcontainers/dockerutils.go b/internal/pkg/devcontainers/dockerutils.go index d73ca10..ca02954 100644 --- a/internal/pkg/devcontainers/dockerutils.go +++ b/internal/pkg/devcontainers/dockerutils.go @@ -271,13 +271,27 @@ func ExecInDevContainer(containerID string, workDir string, args []string) error fmt.Println("Continuing without overriding PATH...") } - statusWriter.Printf("Getting code IPC SOCK") - ipcSock, err := getVscodeIpcSock(containerID) + statusWriter.Printf("Getting VSCODE_IPC_HOOK_CLI") + vscodeIpcSock, err := getVscodeIpcSock(containerID) if err != nil { - ipcSock = "" - fmt.Printf("Warning; Failed to get VS Code IPC SOCK: %s\n", err) + vscodeIpcSock = "" + fmt.Printf("Warning; Failed to get VSCODE_IPC_HOOK_CLI: %s\n", err) fmt.Println("Continuing without setting VSCODE_IPC_HOOK_CLI...") } + statusWriter.Printf("Getting REMOTE_CONTAINERS_IPC") + remoteContainersIpcSock, err := getRemoteContainersIpcSock(containerID) + if err != nil { + remoteContainersIpcSock = "" + fmt.Printf("Warning; Failed to get REMOTE_CONTAINERS_IPC: %s\n", err) + fmt.Println("Continuing without setting REMOTE_CONTAINERS_IPC...") + } + statusWriter.Printf("Getting VSCODE_GIT_IPC_HANDLE") + vscodeGitIpcSock, err := getGitIpcSock(containerID) + if err != nil { + vscodeGitIpcSock = "" + fmt.Printf("Warning; Failed to get VSCODE_GIT_IPC_HANDLE: %s\n", err) + fmt.Println("Continuing without setting VSCODE_GIT_IPC_HANDLE...") + } mountPath := sourceInfo.DockerMount.Destination if workDir == "" { @@ -319,8 +333,14 @@ func ExecInDevContainer(containerID string, workDir string, args []string) error if containerPath != "" { dockerArgs = append(dockerArgs, "--env", "PATH="+containerPath) } - if ipcSock != "" { - dockerArgs = append(dockerArgs, "--env", "VSCODE_IPC_HOOK_CLI="+ipcSock) + if vscodeIpcSock != "" { + dockerArgs = append(dockerArgs, "--env", "VSCODE_IPC_HOOK_CLI="+vscodeIpcSock) + } + if remoteContainersIpcSock != "" { + dockerArgs = append(dockerArgs, "--env", "REMOTE_CONTAINERS_IPC="+remoteContainersIpcSock) + } + if vscodeGitIpcSock != "" { + dockerArgs = append(dockerArgs, "--env", "VSCODE_GIT_IPC_HANDLE="+vscodeGitIpcSock) } dockerArgs = append(dockerArgs, containerID) dockerArgs = append(dockerArgs, args...) @@ -372,6 +392,12 @@ func getVscodeServerPath(containerID string) (string, error) { func getVscodeIpcSock(containerID string) (string, error) { return getLatestFileMatch(containerID, "\"${TMPDIR:-/tmp}\"/vscode-ipc-*") } +func getRemoteContainersIpcSock(containerID string) (string, error) { + return getLatestFileMatch(containerID, "\"${TMPDIR:-/tmp}\"/vscode-remote-containers-ipc-*") +} +func getGitIpcSock(containerID string) (string, error) { + return getLatestFileMatch(containerID, "\"${TMPDIR:-/tmp}\"/vscode-git-*") +} // getLatestFileMatch lists files matching `pattern` in the container and returns the latest filename func getLatestFileMatch(containerID string, pattern string) (string, error) {