From dfd88cbc8c236782a0d2d91db4fcb436dee3c4ec Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Tue, 4 Oct 2022 17:40:16 +0000 Subject: [PATCH 1/2] feat: deprecate relative_path in favor of subdomain --- docs/resources/app.md | 8 ++++---- examples/resources/coder_app/resource.tf | 10 +++++----- provider/app.go | 19 ++++++++++++++----- provider/app_test.go | 4 ++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 8f7c71cd..194d6ab2 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -30,7 +30,7 @@ resource "coder_app" "code-server" { name = "VS Code" icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" url = "http://localhost:13337" - relative_path = true + subdomain = false healthcheck { url = "http://localhost:13337/healthz" interval = 5 @@ -54,6 +54,7 @@ resource "coder_app" "intellij" { ``` + ## Schema ### Required @@ -66,7 +67,7 @@ resource "coder_app" "intellij" { - `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/icons. Use a built-in icon with `data.coder_workspace.me.access_url + "/icons/"`. - `name` (String) A display name to identify the app. -- `relative_path` (Boolean) Specifies whether the URL will be accessed via a relative path or wildcard. Use if wildcard routing is unavailable. +- `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) A URL to be proxied to from inside the workspace. Either "command" or "url" may be specified, but not both. ### Read-Only @@ -74,6 +75,7 @@ resource "coder_app" "intellij" { - `id` (String) The ID of this resource. + ### Nested Schema for `healthcheck` Required: @@ -81,5 +83,3 @@ Required: - `interval` (Number) Duration in seconds to wait between healthcheck requests. - `threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. - `url` (String) HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck.interval seconds. - - diff --git a/examples/resources/coder_app/resource.tf b/examples/resources/coder_app/resource.tf index dfbde849..715f5814 100644 --- a/examples/resources/coder_app/resource.tf +++ b/examples/resources/coder_app/resource.tf @@ -11,11 +11,11 @@ EOF } resource "coder_app" "code-server" { - agent_id = coder_agent.dev.id - name = "VS Code" - icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" - url = "http://localhost:13337" - relative_path = true + agent_id = coder_agent.dev.id + name = "VS Code" + icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" + url = "http://localhost:13337" + subdomain = false healthcheck { url = "http://localhost:13337/healthz" interval = 5 diff --git a/provider/app.go b/provider/app.go index 51e60803..2e0485bb 100644 --- a/provider/app.go +++ b/provider/app.go @@ -60,12 +60,21 @@ func appResource() *schema.Resource { Optional: true, }, "relative_path": { - Type: schema.TypeBool, + 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.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, + "path or wildcard. Use if wildcard routing is unavailable. Defaults to true.", + ForceNew: true, + Optional: true, + }, + "subdomain": { + Type: schema.TypeBool, + Description: "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.", + ForceNew: true, + Optional: true, }, "url": { Type: schema.TypeString, diff --git a/provider/app_test.go b/provider/app_test.go index 6513dcc4..f28ccaf6 100644 --- a/provider/app_test.go +++ b/provider/app_test.go @@ -29,7 +29,7 @@ func TestApp(t *testing.T) { agent_id = coder_agent.dev.id name = "code-server" icon = "builtin:vim" - relative_path = true + subdomain = false url = "http://localhost:13337" healthcheck { url = "http://localhost:13337/healthz" @@ -47,7 +47,7 @@ func TestApp(t *testing.T) { "agent_id", "name", "icon", - "relative_path", + "subdomain", "url", "healthcheck.0.url", "healthcheck.0.interval", From fbf0159f99a941f03c45eb326502b615eaa50146 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Tue, 4 Oct 2022 17:46:00 +0000 Subject: [PATCH 2/2] fixup! feat: deprecate relative_path in favor of subdomain --- docs/resources/app.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 194d6ab2..3b564862 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -26,11 +26,11 @@ EOF } resource "coder_app" "code-server" { - agent_id = coder_agent.dev.id - name = "VS Code" - icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" - url = "http://localhost:13337" - subdomain = false + agent_id = coder_agent.dev.id + name = "VS Code" + icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" + url = "http://localhost:13337" + subdomain = false healthcheck { url = "http://localhost:13337/healthz" interval = 5 @@ -54,7 +54,6 @@ resource "coder_app" "intellij" { ``` - ## Schema ### Required @@ -67,6 +66,7 @@ resource "coder_app" "intellij" { - `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/icons. Use a built-in icon with `data.coder_workspace.me.access_url + "/icons/"`. - `name` (String) A display name to identify the app. +- `relative_path` (Boolean, Deprecated) Specifies whether the URL will be accessed via a relative path or wildcard. Use if wildcard routing is unavailable. Defaults to true. - `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) A URL to be proxied to from inside the workspace. Either "command" or "url" may be specified, but not both. @@ -75,7 +75,6 @@ resource "coder_app" "intellij" { - `id` (String) The ID of this resource. - ### Nested Schema for `healthcheck` Required: @@ -83,3 +82,5 @@ Required: - `interval` (Number) Duration in seconds to wait between healthcheck requests. - `threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. - `url` (String) HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck.interval seconds. + +