diff --git a/docs/resources/agent.md b/docs/resources/agent.md index d12146c2..ee474548 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -75,9 +75,7 @@ resource "kubernetes_pod" "dev" { - `api_key_scope` (String) Controls what API routes the agent token can access. Options: `all` (full access) or `no_user_data` (blocks `/external-auth`, `/gitsshkey`, and `/gitauth` routes) - `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, Deprecated) The starting directory when a user creates a shell session. Defaults to `"$HOME"`. - -~> **Warning:** This attribute is deprecated and will be removed in a future release. Setting `dir` to a value other than `$HOME` will break [Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync). +- `dir` (String) The starting directory when a user creates a shell session. Defaults to `"$HOME"`. SFTP and scp resolve relative and `~/`-prefixed paths against this directory, so use absolute paths for file transfers. - `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)) diff --git a/provider/agent.go b/provider/agent.go index dc662e4a..ff117bb9 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -49,9 +49,9 @@ func agentResource() *schema.Resource { return diag.FromErr(err) } } - return updateInitScript(resourceData, i) - }, + return updateInitScript(resourceData, i) + }, ReadWithoutTimeout: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { token := agentAuthToken(ctx, "") err := resourceData.Set("token", token) @@ -74,9 +74,8 @@ func agentResource() *schema.Resource { } } - return updateInitScript(resourceData, i) - }, - + return updateInitScript(resourceData, i) + }, DeleteContext: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { return nil }, @@ -112,22 +111,17 @@ func agentResource() *schema.Resource { Description: "The authentication type the agent will use. Must be one of: `\"token\"`, `\"google-instance-identity\"`, `\"aws-instance-identity\"`, `\"azure-instance-identity\"`.", ValidateFunc: validation.StringInSlice([]string{"token", "google-instance-identity", "aws-instance-identity", "azure-instance-identity"}, false), }, - "dir": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - Deprecated: "dir has been deprecated and will be removed in a future release.", - Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`." + - "\n\n~> **Warning:** This attribute is deprecated and will be removed in a future release. " + - "Setting `dir` to a value other than `$HOME` will break " + - "[Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync).", - ValidateFunc: helpers.WarnDirNotHome, - }, - + "dir": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`. " + + "SFTP and scp resolve relative and `~/`-prefixed paths against this directory, " + + "so use absolute paths for file transfers.", + }, "env": { ForceNew: true, Description: "A mapping of environment variables to set inside the workspace.", - Type: schema.TypeMap, Optional: true, }, diff --git a/provider/helpers/validation.go b/provider/helpers/validation.go index 0167877a..8e22ecf5 100644 --- a/provider/helpers/validation.go +++ b/provider/helpers/validation.go @@ -21,20 +21,6 @@ func ValidateURL(value any, label string) ([]string, []error) { return nil, nil } -// WarnDirNotHome returns a warning if dir is set to a value other -// than $HOME, because this breaks Coder Desktop file sync. The dir -// attribute is deprecated and will be removed in a future release. -func WarnDirNotHome(val interface{}, _ string) ([]string, []error) { - d, ok := val.(string) - if !ok || d == "" || d == "$HOME" || d == "~" { - return nil, nil - } - return []string{ - `"dir" is deprecated and will be removed in a future release.`, - `Setting "dir" to a value other than $HOME will break Coder Desktop file sync.`, - }, nil -} - // ValidateExternalURL validates that value is a URL the browser's URL can parse. // An external app URL must carry a scheme and hostname func ValidateExternalURL(value string) error { diff --git a/provider/helpers/validation_test.go b/provider/helpers/validation_test.go index 41ac35e1..daee783b 100644 --- a/provider/helpers/validation_test.go +++ b/provider/helpers/validation_test.go @@ -150,60 +150,6 @@ func TestValidateURL(t *testing.T) { } } -func TestWarnDirNotHome(t *testing.T) { - tests := []struct { - name string - value interface{} - warnCount int - }{ - // No warnings expected. - { - name: "empty string", - value: "", - warnCount: 0, - }, - { - name: "$HOME", - value: "$HOME", - warnCount: 0, - }, - { - name: "tilde", - value: "~", - warnCount: 0, - }, - { - name: "non-string type", - value: 123, - warnCount: 0, - }, - // Warnings expected. - { - name: "absolute path", - value: "/workspace", - warnCount: 2, - }, - { - name: "relative path", - value: "projects/foo", - warnCount: 2, - }, - { - name: "tilde subdir", - value: "~/projects", - warnCount: 2, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - warnings, errors := WarnDirNotHome(tt.value, "dir") - require.Empty(t, errors, "expected no errors") - require.Len(t, warnings, tt.warnCount) - }) - } -} - func TestValidateExternalURL(t *testing.T) { tests := []struct { name string