mirror of https://github.com/coder/coder.git
fix: VSCode desktop connection (#7120)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
parent
942aba3a66
commit
bb43713d38
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue