Skip to content
Draft
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
2 changes: 2 additions & 0 deletions docs/resources/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ resource "kubernetes_pod" "dev" {
- `auth` (String) The authentication type the agent will use. Must be one of: `"token"`, `"google-instance-identity"`, `"aws-instance-identity"`, `"azure-instance-identity"`.
- `connection_timeout` (Number) Time in seconds until the agent is marked as timed out when a connection with the server cannot be established. A value of zero never marks the agent as timed out.
- `dir` (String) The starting directory when a user creates a shell session. Defaults to `"$HOME"`.

~> **Warning:** Setting `dir` to a value other than `$HOME` will break [Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync).
- `display_apps` (Block Set, Max: 1) The list of built-in apps to display in the agent bar. (see [below for nested schema](#nestedblock--display_apps))
- `env` (Map of String) A mapping of environment variables to set inside the workspace.
- `metadata` (Block List) Each `metadata` block defines a single item consisting of a key/value pair. This feature is in alpha and may break in future releases. (see [below for nested schema](#nestedblock--metadata))
Expand Down
31 changes: 27 additions & 4 deletions provider/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ func agentResource() *schema.Resource {
return diag.FromErr(err)
}
}

return updateInitScript(resourceData, i)
diags := updateInitScript(resourceData, i)
if dir, ok := resourceData.GetOk("dir"); ok {
if d, _ := dir.(string); d != "" && d != "$HOME" && d != "~" {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: `"dir" is not set to $HOME`,
Detail: `Setting "dir" to a value other than $HOME will break Coder Desktop file sync.`,
})
}
}
return diags
},

ReadWithoutTimeout: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics {
token := agentAuthToken(ctx, "")
err := resourceData.Set("token", token)
Expand All @@ -74,8 +84,19 @@ func agentResource() *schema.Resource {
}
}

return updateInitScript(resourceData, i)
diags := updateInitScript(resourceData, i)
if dir, ok := resourceData.GetOk("dir"); ok {
if d, _ := dir.(string); d != "" && d != "$HOME" && d != "~" {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: `"dir" is not set to $HOME`,
Detail: `Setting "dir" to a value other than $HOME will break Coder Desktop file sync.`,
})
}
}
return diags
},

DeleteContext: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics {
return nil
},
Expand Down Expand Up @@ -115,7 +136,9 @@ func agentResource() *schema.Resource {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`.",
Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`." +
"\n\n~> **Warning:** Setting `dir` to a value other than `$HOME` will break " +
"[Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync).",
},
"env": {
ForceNew: true,
Expand Down
Loading