Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: VSCode desktop connection #7120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1407,5 +1407,14 @@ func expandDirectory(dir string) (string, error) {
}
dir = filepath.Join(home, dir[1:])
}
return os.ExpandEnv(dir), nil
dir = os.ExpandEnv(dir)

if !filepath.IsAbs(dir) {
home, err := userHomeDir()
if err != nil {
return "", err
}
dir = filepath.Join(home, dir)
}
return dir, nil
}
16 changes: 16 additions & 0 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,22 @@ func TestAgent_Startup(t *testing.T) {
require.Equal(t, homeDir, client.getStartup().ExpandedDirectory)
})

t.Run("NotAbsoluteDirectory", func(t *testing.T) {
t.Parallel()

_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{
StartupScript: "true",
StartupScriptTimeout: 30 * time.Second,
Directory: "coder/coder",
}, 0)
assert.Eventually(t, func() bool {
return client.getStartup().Version != ""
}, testutil.WaitShort, testutil.IntervalFast)
homeDir, err := os.UserHomeDir()
require.NoError(t, err)
require.Equal(t, filepath.Join(homeDir, "coder/coder"), client.getStartup().ExpandedDirectory)
})

t.Run("HomeEnvironmentVariable", func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 6 additions & 0 deletions docs/templates/open-in-coder.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ To support any infrastructure and software stack, Coder provides a generic appro
}
```

> Note: The `dir` attribute can be set in multiple ways, for example:
>
> - `~/coder`
> - `/home/coder/coder`
> - `coder` (relative to the home directory)

- If you want the template to support any repository via [parameters](./parameters.md)

```hcl
Expand Down