Skip to content

Commit

Permalink
Fix workspace location
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel committed Jun 21, 2022
1 parent 8286f66 commit 9f29952
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 7 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ var runCmd = &cobra.Command{
return err
}

if cfg.CheckoutLocation == "" {
cfg.CheckoutLocation = filepath.Base(rootOpts.Workdir)
}
if cfg.WorkspaceLocation == "" {
cfg.WorkspaceLocation = cfg.CheckoutLocation
}

runtime, err := getRuntime(rootOpts.Workdir)
if err != nil {
return err
Expand Down
16 changes: 7 additions & 9 deletions pkg/runtime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,15 @@ func (dr docker) StartWorkspace(ctx context.Context, workspaceImage string, cfg
logs = io.Discard
}

checkoutLocation := cfg.CheckoutLocation
if checkoutLocation == "" {
checkoutLocation = filepath.Base(dr.Workdir)
if cfg.CheckoutLocation == "" {
return fmt.Errorf("missing checkout location")
}
workspaceLocation := cfg.WorkspaceLocation
if workspaceLocation == "" {
workspaceLocation = checkoutLocation
if cfg.WorkspaceLocation == "" {
return fmt.Errorf("missing workspace location")
}

name := fmt.Sprintf("rungp-%d", time.Now().UnixNano())
args := []string{"run", "--rm", "--user", "root", "--privileged", "-p", fmt.Sprintf("%d:22999", opts.IDEPort), "-v", fmt.Sprintf("%s:%s", dr.Workdir, filepath.Join("/workspace", checkoutLocation)), "--name", name}
args := []string{"run", "--rm", "--user", "root", "--privileged", "-p", fmt.Sprintf("%d:22999", opts.IDEPort), "-v", fmt.Sprintf("%s:%s", dr.Workdir, filepath.Join("/workspace", cfg.CheckoutLocation)), "--name", name}

if (runtime.GOOS == "darwin" || runtime.GOOS == "linux") && dr.Command == "docker" {
args = append(args, "-v", "/var/run/docker.sock:/var/run/docker.sock")
Expand All @@ -174,8 +172,8 @@ func (dr docker) StartWorkspace(ctx context.Context, workspaceImage string, cfg
"GITPOD_WORKSPACE_URL": "http://localhost",
"GITPOD_THEIA_PORT": "23000",
"GITPOD_IDE_ALIAS": "code",
"THEIA_WORKSPACE_ROOT": filepath.Join("/workspace", workspaceLocation),
"GITPOD_REPO_ROOT": filepath.Join("/workspace", checkoutLocation),
"THEIA_WORKSPACE_ROOT": filepath.Join("/workspace", cfg.WorkspaceLocation),
"GITPOD_REPO_ROOT": filepath.Join("/workspace", cfg.CheckoutLocation),
"GITPOD_PREVENT_METADATA_ACCESS": "false",
"GITPOD_WORKSPACE_ID": "a-random-name",
"GITPOD_TASKS": string(tasks),
Expand Down

0 comments on commit 9f29952

Please sign in to comment.