From 70fe3555bf2fe761a6e36052a086e5c32f246982 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 4 Jul 2024 16:17:04 +0300 Subject: [PATCH 1/4] chore!: remove deprecated `name` and `relative_path` fields from app resource The `name` and `relative_path` fields in the app resource have been deprecated. This commit removes these fields from the codebase to align with the updated documentation and best practices. --- docs/resources/app.md | 2 -- provider/app.go | 17 ----------------- 2 files changed, 19 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index f61ed799..1cb5d08b 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -64,9 +64,7 @@ resource "coder_app" "vim" { - `external` (Boolean) Specifies whether `url` is opened on the client machine instead of proxied through the workspace. - `healthcheck` (Block Set, Max: 1) HTTP health checking to determine the application readiness. (see [below for nested schema](#nestedblock--healthcheck)) - `icon` (String) A URL to an icon that will display in the dashboard. View built-in icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a built-in icon with `"${data.coder_workspace.me.access_url}/icon/"`. -- `name` (String, **Deprecated**: `name` on apps is deprecated, use `display_name` instead) A display name to identify the app. - `order` (Number) The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order). -- `relative_path` (Boolean, **Deprecated**: `relative_path` on apps is deprecated, use `subdomain` instead.) Specifies whether the URL will be accessed via a relative path or wildcard. Use if wildcard routing is unavailable. Defaults to `true`. - `share` (String) Determines the level which the application is shared at. Valid levels are `"owner"` (default), `"authenticated"` and `"public"`. Level `"owner"` disables sharing on the app, so only the workspace owner can access it. Level `"authenticated"` shares the app with all authenticated users. Level `"public"` shares it with any user, including unauthenticated users. Permitted application sharing levels can be configured site-wide via a flag on `coder server` (Enterprise only). - `subdomain` (Boolean) Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder. If wildcards have not been setup by the administrator then apps with `subdomain` set to `true` will not be accessible. Defaults to `false`. - `url` (String) An external url if `external=true` or a URL to be proxied to from inside the workspace. This should be of the form `http://localhost:PORT[/SUBPATH]`. Either `command` or `url` may be specified, but not both. diff --git a/provider/app.go b/provider/app.go index 91c08f0f..754b0e2a 100644 --- a/provider/app.go +++ b/provider/app.go @@ -96,14 +96,6 @@ func appResource() *schema.Resource { ForceNew: true, Optional: true, }, - "name": { - Type: schema.TypeString, - Description: "A display name to identify the app.", - Deprecated: "`name` on apps is deprecated, use `display_name` instead", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"display_name"}, - }, "subdomain": { Type: schema.TypeBool, Description: "Determines whether the app will be accessed via it's own " + @@ -113,15 +105,6 @@ func appResource() *schema.Resource { ForceNew: true, Optional: true, }, - "relative_path": { - Type: schema.TypeBool, - Deprecated: "`relative_path` on apps is deprecated, use `subdomain` instead.", - Description: "Specifies whether the URL will be accessed via a relative " + - "path or wildcard. Use if wildcard routing is unavailable. Defaults to `true`.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"subdomain"}, - }, "share": { Type: schema.TypeString, Description: "Determines the level which the application " + From b6d2345b07d51ffd53a98665f7271a0e1962bb3c Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 4 Jul 2024 16:18:05 +0300 Subject: [PATCH 2/4] chore!: remove deprecated attribute from `coder_agent` --- docs/resources/agent.md | 3 --- provider/agent.go | 29 ----------------------------- 2 files changed, 32 deletions(-) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index e444d2d7..8c786d6e 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -76,15 +76,12 @@ resource "kubernetes_pod" "dev" { - `dir` (String) The starting directory when a user creates a shell session. Defaults to `"$HOME"`. - `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. -- `login_before_ready` (Boolean, **Deprecated**: Configure `startup_script_behavior` instead. This attribute will be removed in a future version of the provider.) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the `startup_script` is done and has exited. When enabled, users may see an incomplete workspace when logging in. - `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)) - `motd_file` (String) The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be `"/etc/motd"`. - `order` (Number) The order determines the position of agents in the UI presentation. The lowest order is shown first and agents with equal order are sorted by name (ascending order). - `shutdown_script` (String) A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped. This option is an alias for defining a `coder_script` resource with `run_on_stop` set to `true`. -- `shutdown_script_timeout` (Number, **Deprecated**: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time. - `startup_script` (String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready. This option is an alias for defining a `coder_script` resource with `run_on_start` set to `true`. - `startup_script_behavior` (String) This option sets the behavior of the `startup_script`. When set to `"blocking"`, the `startup_script` must exit before the workspace is ready. When set to `"non-blocking"`, the `startup_script` may run in the background and the workspace will be ready immediately. Default is `"non-blocking"`, although `"blocking"` is recommended. This option is an alias for defining a `coder_script` resource with `start_blocks_login` set to `true` (blocking). -- `startup_script_timeout` (Number, **Deprecated**: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time. - `troubleshooting_url` (String) A URL to a document with instructions for troubleshooting problems with the agent. ### Read-Only diff --git a/provider/agent.go b/provider/agent.go index 352dd5d9..396f73db 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -128,30 +128,12 @@ func agentResource() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "startup_script_timeout": { - Type: schema.TypeInt, - Default: 300, - ForceNew: true, - Optional: true, - Description: "Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.", - Deprecated: "This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.", - ValidateFunc: validation.IntAtLeast(1), - }, "shutdown_script": { Type: schema.TypeString, ForceNew: true, Optional: true, Description: "A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped. This option is an alias for defining a `coder_script` resource with `run_on_stop` set to `true`.", }, - "shutdown_script_timeout": { - Type: schema.TypeInt, - Default: 300, - ForceNew: true, - Optional: true, - Description: "Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.", - Deprecated: "This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.", - ValidateFunc: validation.IntAtLeast(1), - }, "token": { ForceNew: true, Sensitive: true, @@ -179,17 +161,6 @@ func agentResource() *schema.Resource { Optional: true, Description: "The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be `\"/etc/motd\"`.", }, - "login_before_ready": { - // Note: When this is removed, "startup_script_behavior" should - // be set to "non-blocking" by default (instead of empty string). - Type: schema.TypeBool, - Default: true, - ForceNew: true, - Optional: true, - Description: "This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the `startup_script` is done and has exited. When enabled, users may see an incomplete workspace when logging in.", - Deprecated: "Configure `startup_script_behavior` instead. This attribute will be removed in a future version of the provider.", - ConflictsWith: []string{"startup_script_behavior"}, - }, "startup_script_behavior": { // Note: Our default value is "non-blocking" but we do not set // it here because we want to be able to differentiate between From 9995bf53a3dfb636b347c189256df0ef675d3c34 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 4 Jul 2024 16:27:17 +0300 Subject: [PATCH 3/4] fix tests --- provider/agent_test.go | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/provider/agent_test.go b/provider/agent_test.go index 491e59f9..0df2cf2d 100644 --- a/provider/agent_test.go +++ b/provider/agent_test.go @@ -34,11 +34,9 @@ func TestAgent(t *testing.T) { hi = "test" } startup_script = "echo test" - startup_script_timeout = 120 troubleshooting_url = "https://example.com/troubleshoot" motd_file = "/etc/motd" shutdown_script = "echo bye bye" - shutdown_script_timeout = 120 order = 4 } `, @@ -55,12 +53,10 @@ func TestAgent(t *testing.T) { "dir", "env.hi", "startup_script", - "startup_script_timeout", "connection_timeout", "troubleshooting_url", "motd_file", "shutdown_script", - "shutdown_script_timeout", "order", } { value := resource.Primary.Attributes[key] @@ -109,34 +105,6 @@ func TestAgent_StartupScriptBehavior(t *testing.T) { require.Equal(t, "non-blocking", state.Primary.Attributes["startup_script_behavior"]) }, }, - { - Name: "login_before_ready (deprecated)", - Config: ` - resource "coder_agent" "new" { - os = "linux" - arch = "amd64" - login_before_ready = false - } - `, - Check: func(state *terraform.ResourceState) { - require.Equal(t, "false", state.Primary.Attributes["login_before_ready"]) - // startup_script_behavior must be empty, this indicates that - // login_before_ready should be used instead. - require.Equal(t, "", state.Primary.Attributes["startup_script_behavior"]) - }, - }, - { - Name: "no login_before_ready with startup_script_behavior", - Config: ` - resource "coder_agent" "new" { - os = "linux" - arch = "amd64" - login_before_ready = false - startup_script_behavior = "blocking" - } - `, - ExpectError: regexp.MustCompile("conflicts with"), - }, } { tc := tc t.Run(tc.Name, func(t *testing.T) { From 533c613333954694fc04465dd415f8d22b143031 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 4 Jul 2024 16:42:31 +0300 Subject: [PATCH 4/4] fixup tests --- provider/agent.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/provider/agent.go b/provider/agent.go index 396f73db..d0ce4070 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -162,18 +162,12 @@ func agentResource() *schema.Resource { Description: "The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be `\"/etc/motd\"`.", }, "startup_script_behavior": { - // Note: Our default value is "non-blocking" but we do not set - // it here because we want to be able to differentiate between - // the user setting this or "login_before_ready". For all - // intents and purposes, until deprecation, setting - // "login_before_ready = false" is equivalent to setting - // "startup_script_behavior = blocking". - Type: schema.TypeString, - ForceNew: true, - Optional: true, - Description: "This option sets the behavior of the `startup_script`. When set to `\"blocking\"`, the `startup_script` must exit before the workspace is ready. When set to `\"non-blocking\"`, the `startup_script` may run in the background and the workspace will be ready immediately. Default is `\"non-blocking\"`, although `\"blocking\"` is recommended. This option is an alias for defining a `coder_script` resource with `start_blocks_login` set to `true` (blocking).", - ValidateFunc: validation.StringInSlice([]string{"blocking", "non-blocking"}, false), - ConflictsWith: []string{"login_before_ready"}, + Type: schema.TypeString, + Default: "non-blocking", + ForceNew: true, + Optional: true, + Description: "This option sets the behavior of the `startup_script`. When set to `\"blocking\"`, the `startup_script` must exit before the workspace is ready. When set to `\"non-blocking\"`, the `startup_script` may run in the background and the workspace will be ready immediately. Default is `\"non-blocking\"`, although `\"blocking\"` is recommended. This option is an alias for defining a `coder_script` resource with `start_blocks_login` set to `true` (blocking).", + ValidateFunc: validation.StringInSlice([]string{"blocking", "non-blocking"}, false), }, "metadata": { Type: schema.TypeList,