Skip to content

Commit

Permalink
fix: compile vscode extensions with user state (#1564)
Browse files Browse the repository at this point in the history
* fix: compile vscode extensions with user state

Signed-off-by: hang lv <xlv20@fudan.edu.cn>

* fix: install extension in parallel

Signed-off-by: hang lv <xlv20@fudan.edu.cn>

* fix: merge diffed extensions states

Signed-off-by: hang lv <xlv20@fudan.edu.cn>

---------

Signed-off-by: hang lv <xlv20@fudan.edu.cn>
  • Loading branch information
n063h authored Apr 20, 2023
1 parent bc0eaf8 commit f3acdff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions pkg/lang/ir/v1/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,11 @@ func (g *generalGraph) CompileLLB(uid, gid int) (llb.State, error) {
if err != nil {
return llb.State{}, errors.Wrap(err, "failed to compile entrypoint")
}
vscode, err := g.compileVSCode()
vscode, err := g.compileVSCode(entrypoint)
if err != nil {
return llb.State{}, errors.Wrap(err, "failed to compile VSCode extensions")
}
copy = llb.Merge([]llb.State{
entrypoint,
vscode,
}, llb.WithCustomName("[internal] final dev environment"))
copy = vscode
}

// it's necessary to exec `run` with the desired user
Expand Down
10 changes: 5 additions & 5 deletions pkg/lang/ir/v1/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
"github.com/tensorchord/envd/pkg/util/fileutil"
)

func (g generalGraph) compileVSCode() (llb.State, error) {
func (g generalGraph) compileVSCode(root llb.State) (llb.State, error) {
if len(g.VSCodePlugins) == 0 {
return llb.Scratch(), nil
return root, nil
}
inputs := []llb.State{}
inputs := []llb.State{root}
for _, p := range g.VSCodePlugins {
vscodeClient, err := vscode.NewClient(vscode.MarketplaceVendorOpenVSX)
if err != nil {
Expand All @@ -45,14 +45,14 @@ func (g generalGraph) compileVSCode() (llb.State, error) {
return llb.State{}, err
}
g.Writer.LogVSCodePlugin(p, compileui.ActionEnd, cached)
ext := llb.Scratch().File(llb.Copy(llb.Local(flag.FlagCacheDir),
ext := root.File(llb.Copy(llb.Local(flag.FlagCacheDir),
vscodeClient.PluginPath(p),
fileutil.EnvdHomeDir(".vscode-server", "extensions", p.String()),
&llb.CopyInfo{
CreateDestPath: true,
}, llb.WithUIDGID(g.uid, g.gid)),
llb.WithCustomNamef("install vscode plugin %s", p.String()))
inputs = append(inputs, ext)
inputs = append(inputs, llb.Diff(root, ext))
}
layer := llb.Merge(inputs, llb.WithCustomName("merging plugins for vscode"))
return layer, nil
Expand Down

0 comments on commit f3acdff

Please sign in to comment.