From 1a15234ff80e04d3fdd0f3a1a605b9e40e86fa5a Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 18:31:05 +0000 Subject: [PATCH 01/10] feat: add healthcheck parameters to coder_app --- docs/resources/app.md | 14 ++++++---- docs/resources/metadata.md | 12 ++++---- examples/resources/coder_app/resource.tf | 10 +++---- examples/resources/coder_metadata/resource.tf | 12 ++++---- internal/provider/provider.go | 28 +++++++++++++++++++ 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 698f52a5..1cbbfdf1 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" - 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" + relative_path = true } resource "coder_app" "vim" { @@ -58,6 +58,10 @@ resource "coder_app" "intellij" { ### Optional - `command` (String) A command to run in a terminal opening this app. In the web, this will open in a new tab. In the CLI, this will SSH and execute the command. Either "command" or "url" may be specified, but not both. +- `healthcheck_enabled` (Boolean) Run a HTTP request periodically to determine the application readiness. +- `healthcheck_interval` (Number) Duration in seconds to wait between healthcheck requests. +- `healthcheck_threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. +- `healthcheck_url` (String) HTTP address used determine the application readiness. - `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. diff --git a/docs/resources/metadata.md b/docs/resources/metadata.md index 16c8e6be..a4e7e59e 100644 --- a/docs/resources/metadata.md +++ b/docs/resources/metadata.md @@ -21,25 +21,25 @@ resource "kubernetes_pod" "dev" { } resource "tls_private_key" "example_key_pair" { - algorithm = "ECDSA" + algorithm = "ECDSA" ecdsa_curve = "P256" } resource "coder_metadata" "pod_info" { - count = data.coder_workspace.me.start_count + count = data.coder_workspace.me.start_count resource_id = kubernetes_pod.dev[0].id item { - key = "description" + key = "description" value = "This description will show up in the Coder dashboard." } item { - key = "pod_uid" + key = "pod_uid" value = kubernetes_pod.dev[0].uid } item { - key = "public_key" + key = "public_key" value = tls_private_key.example_key_pair.public_key_openssh - # The value of this item will be hidden from view by default + # The value of this item will be hidden from view by default sensitive = true } } diff --git a/examples/resources/coder_app/resource.tf b/examples/resources/coder_app/resource.tf index d72a0047..1bbb7456 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" + relative_path = true } resource "coder_app" "vim" { diff --git a/examples/resources/coder_metadata/resource.tf b/examples/resources/coder_metadata/resource.tf index 73222c8b..934928a1 100644 --- a/examples/resources/coder_metadata/resource.tf +++ b/examples/resources/coder_metadata/resource.tf @@ -6,25 +6,25 @@ resource "kubernetes_pod" "dev" { } resource "tls_private_key" "example_key_pair" { - algorithm = "ECDSA" + algorithm = "ECDSA" ecdsa_curve = "P256" } resource "coder_metadata" "pod_info" { - count = data.coder_workspace.me.start_count + count = data.coder_workspace.me.start_count resource_id = kubernetes_pod.dev[0].id item { - key = "description" + key = "description" value = "This description will show up in the Coder dashboard." } item { - key = "pod_uid" + key = "pod_uid" value = kubernetes_pod.dev[0].uid } item { - key = "public_key" + key = "public_key" value = tls_private_key.example_key_pair.public_key_openssh - # The value of this item will be hidden from view by default + # The value of this item will be hidden from view by default sensitive = true } } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 2829ed50..c05aa52c 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -373,6 +373,34 @@ func New() *schema.Provider { Optional: true, ConflictsWith: []string{"command"}, }, + "healthcheck_enabled": { + Type: schema.TypeBool, + Description: "Run a HTTP request periodically to determine the application readiness.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + }, + "healthcheck_url": { + Type: schema.TypeString, + Description: "HTTP address used determine the application readiness.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + }, + "healthcheck_interval": { + Type: schema.TypeInt, + Description: "Duration in seconds to wait between healthcheck requests.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + }, + "healthcheck_threshold": { + Type: schema.TypeInt, + Description: "Number of consecutive heathcheck failures before returning an unhealthy status.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + }, }, }, "coder_metadata": { From 8d5dbdc06f30822ce91861eb2432f05106f45d04 Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 20:57:53 +0000 Subject: [PATCH 02/10] remove healthcheck_enabled --- docs/resources/app.md | 1 - internal/provider/provider.go | 10 +++------- internal/provider/provider_test.go | 6 ++++++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 1cbbfdf1..030a473a 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -58,7 +58,6 @@ resource "coder_app" "intellij" { ### Optional - `command` (String) A command to run in a terminal opening this app. In the web, this will open in a new tab. In the CLI, this will SSH and execute the command. Either "command" or "url" may be specified, but not both. -- `healthcheck_enabled` (Boolean) Run a HTTP request periodically to determine the application readiness. - `healthcheck_interval` (Number) Duration in seconds to wait between healthcheck requests. - `healthcheck_threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. - `healthcheck_url` (String) HTTP address used determine the application readiness. diff --git a/internal/provider/provider.go b/internal/provider/provider.go index c05aa52c..3eec3665 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -373,19 +373,13 @@ func New() *schema.Provider { Optional: true, ConflictsWith: []string{"command"}, }, - "healthcheck_enabled": { - Type: schema.TypeBool, - Description: "Run a HTTP request periodically to determine the application readiness.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - }, "healthcheck_url": { Type: schema.TypeString, Description: "HTTP address used determine the application readiness.", ForceNew: true, Optional: true, ConflictsWith: []string{"command"}, + RequiredWith: []string{"healthcheck_interval", "healthcheck_threshold"}, }, "healthcheck_interval": { Type: schema.TypeInt, @@ -393,6 +387,7 @@ func New() *schema.Provider { ForceNew: true, Optional: true, ConflictsWith: []string{"command"}, + RequiredWith: []string{"healthcheck_url", "healthcheck_threshold"}, }, "healthcheck_threshold": { Type: schema.TypeInt, @@ -400,6 +395,7 @@ func New() *schema.Provider { ForceNew: true, Optional: true, ConflictsWith: []string{"command"}, + RequiredWith: []string{"healthcheck_interval", "healthcheck_url"}, }, }, }, diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 2e7acbbb..cd88b7c1 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -221,6 +221,9 @@ func TestApp(t *testing.T) { icon = "builtin:vim" relative_path = true url = "http://localhost:13337" + healthcheck_url = "http://localhost:13337/healthz" + healthcheck_interval = 5 + healthcheck_threshold = 6 } `, Check: func(state *terraform.State) error { @@ -234,6 +237,9 @@ func TestApp(t *testing.T) { "icon", "relative_path", "url", + "healthcheck_url", + "healthcheck_interval", + "healthcheck_threshold", } { value := resource.Primary.Attributes[key] t.Logf("%q = %q", key, value) From b32a9a25c6390f0648c58fd1ffa3b92d13e10aac Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:03:22 +0000 Subject: [PATCH 03/10] docs --- docs/resources/app.md | 2 +- internal/provider/provider.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 030a473a..25c9a0ce 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -60,7 +60,7 @@ resource "coder_app" "intellij" { - `command` (String) A command to run in a terminal opening this app. In the web, this will open in a new tab. In the CLI, this will SSH and execute the command. Either "command" or "url" may be specified, but not both. - `healthcheck_interval` (Number) Duration in seconds to wait between healthcheck requests. - `healthcheck_threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. -- `healthcheck_url` (String) HTTP address used determine the application readiness. +- `healthcheck_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. - `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. diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 3eec3665..52ef8b60 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -375,7 +375,7 @@ func New() *schema.Provider { }, "healthcheck_url": { Type: schema.TypeString, - Description: "HTTP address used determine the application readiness.", + Description: "HTTP address used determine the application readiness. " + "A successful health check is a HTTP response code less than 500 returned before healthcheck_interval seconds.", ForceNew: true, Optional: true, ConflictsWith: []string{"command"}, From 5976de2167ce9e5cf600260e40eae4b9ff706feb Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:06:35 +0000 Subject: [PATCH 04/10] examples --- docs/resources/app.md | 3 +++ examples/resources/coder_app/resource.tf | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/resources/app.md b/docs/resources/app.md index 25c9a0ce..d8962add 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -31,6 +31,9 @@ resource "coder_app" "code-server" { icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" url = "http://localhost:13337" relative_path = true + healthcheck_url = "http://localhost:13337/healthz" + healthcheck_interval = 5 + healthcheck_threshold = 6 } resource "coder_app" "vim" { diff --git a/examples/resources/coder_app/resource.tf b/examples/resources/coder_app/resource.tf index 1bbb7456..5b4b81c2 100644 --- a/examples/resources/coder_app/resource.tf +++ b/examples/resources/coder_app/resource.tf @@ -16,6 +16,9 @@ resource "coder_app" "code-server" { icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" url = "http://localhost:13337" relative_path = true + healthcheck_url = "http://localhost:13337/healthz" + healthcheck_interval = 5 + healthcheck_threshold = 6 } resource "coder_app" "vim" { From b964ecd2ca1b016c03eae0293d0a3a56c355804c Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:11:19 +0000 Subject: [PATCH 05/10] make fmt --- examples/resources/coder_app/resource.tf | 14 +++++++------- internal/provider/provider.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/resources/coder_app/resource.tf b/examples/resources/coder_app/resource.tf index 5b4b81c2..a0653119 100644 --- a/examples/resources/coder_app/resource.tf +++ b/examples/resources/coder_app/resource.tf @@ -11,13 +11,13 @@ 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 - healthcheck_url = "http://localhost:13337/healthz" - healthcheck_interval = 5 + 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 + healthcheck_url = "http://localhost:13337/healthz" + healthcheck_interval = 5 healthcheck_threshold = 6 } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 52ef8b60..b289cc84 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -375,7 +375,7 @@ func New() *schema.Provider { }, "healthcheck_url": { Type: schema.TypeString, - Description: "HTTP address used determine the application readiness. " + "A successful health check is a HTTP response code less than 500 returned before healthcheck_interval seconds.", + Description: "HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck_interval seconds.", ForceNew: true, Optional: true, ConflictsWith: []string{"command"}, From 05394215e7b719e42f36b858e01118c662a0d352 Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:13:15 +0000 Subject: [PATCH 06/10] make gen --- docs/resources/app.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index d8962add..1d98a7e0 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -26,13 +26,13 @@ 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 - healthcheck_url = "http://localhost:13337/healthz" - healthcheck_interval = 5 + 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 + healthcheck_url = "http://localhost:13337/healthz" + healthcheck_interval = 5 healthcheck_threshold = 6 } From c445def8226bb6275ce8b428e03332dd169f97d0 Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:26:52 +0000 Subject: [PATCH 07/10] move to healthcheck block --- docs/resources/app.md | 21 ++++++--- examples/resources/coder_app/resource.tf | 18 ++++---- internal/provider/provider.go | 56 ++++++++++++++---------- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 1d98a7e0..1a1807bd 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -31,9 +31,11 @@ resource "coder_app" "code-server" { icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" url = "http://localhost:13337" relative_path = true - healthcheck_url = "http://localhost:13337/healthz" - healthcheck_interval = 5 - healthcheck_threshold = 6 + healthcheck { + url = "http://localhost:13337/healthz" + interval = 5 + threshold = 6 + } } resource "coder_app" "vim" { @@ -61,9 +63,7 @@ resource "coder_app" "intellij" { ### Optional - `command` (String) A command to run in a terminal opening this app. In the web, this will open in a new tab. In the CLI, this will SSH and execute the command. Either "command" or "url" may be specified, but not both. -- `healthcheck_interval` (Number) Duration in seconds to wait between healthcheck requests. -- `healthcheck_threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. -- `healthcheck_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. +- `healthcheck` (Block Set) 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. @@ -73,4 +73,13 @@ resource "coder_app" "intellij" { - `id` (String) The ID of this resource. + +### Nested Schema for `healthcheck` + +Optional: + +- `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 a0653119..6f4a34dd 100644 --- a/examples/resources/coder_app/resource.tf +++ b/examples/resources/coder_app/resource.tf @@ -11,14 +11,16 @@ 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 - healthcheck_url = "http://localhost:13337/healthz" - healthcheck_interval = 5 - healthcheck_threshold = 6 + 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 + healthcheck { + url = "http://localhost:13337/healthz" + interval = 5 + threshold = 6 + } } resource "coder_app" "vim" { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b289cc84..17cb1b75 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -373,29 +373,39 @@ func New() *schema.Provider { Optional: true, ConflictsWith: []string{"command"}, }, - "healthcheck_url": { - Type: schema.TypeString, - Description: "HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck_interval seconds.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - RequiredWith: []string{"healthcheck_interval", "healthcheck_threshold"}, - }, - "healthcheck_interval": { - Type: schema.TypeInt, - Description: "Duration in seconds to wait between healthcheck requests.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - RequiredWith: []string{"healthcheck_url", "healthcheck_threshold"}, - }, - "healthcheck_threshold": { - Type: schema.TypeInt, - Description: "Number of consecutive heathcheck failures before returning an unhealthy status.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - RequiredWith: []string{"healthcheck_interval", "healthcheck_url"}, + "healthcheck": { + Type: schema.TypeSet, + Description: "HTTP health checking to determine the application readiness.", + ForceNew: true, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Description: "HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck.interval seconds.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + RequiredWith: []string{"healthcheck.interval", "healthcheck.threshold"}, + }, + "interval": { + Type: schema.TypeInt, + Description: "Duration in seconds to wait between healthcheck requests.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + RequiredWith: []string{"healthcheck.url", "healthcheck.threshold"}, + }, + "threshold": { + Type: schema.TypeInt, + Description: "Number of consecutive heathcheck failures before returning an unhealthy status.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, + RequiredWith: []string{"healthcheck.interval", "healthcheck.url"}, + }, + }, + }, }, }, }, From 5171e8e99639ecf930c734e8ab5c13490724593b Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:29:01 +0000 Subject: [PATCH 08/10] more docs --- docs/resources/app.md | 10 +++++----- internal/provider/provider_test.go | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 1a1807bd..9429e56f 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" - 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" + relative_path = true healthcheck { url = "http://localhost:13337/healthz" interval = 5 diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index cd88b7c1..782ddb19 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -221,9 +221,10 @@ func TestApp(t *testing.T) { icon = "builtin:vim" relative_path = true url = "http://localhost:13337" - healthcheck_url = "http://localhost:13337/healthz" - healthcheck_interval = 5 - healthcheck_threshold = 6 + healthcheck{ + url = "http://localhost:13337/healthz" + interval = 5 + threshold = 6 } `, Check: func(state *terraform.State) error { @@ -237,9 +238,9 @@ func TestApp(t *testing.T) { "icon", "relative_path", "url", - "healthcheck_url", - "healthcheck_interval", - "healthcheck_threshold", + "healthcheck.url", + "healthcheck.interval", + "healthcheck.threshold", } { value := resource.Primary.Attributes[key] t.Logf("%q = %q", key, value) From 46d279dbb8b1f087fcf5bd1c9d36a4defc851c79 Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:29:59 +0000 Subject: [PATCH 09/10] fix --- internal/provider/provider_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 782ddb19..57cd3d5d 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -221,10 +221,11 @@ func TestApp(t *testing.T) { icon = "builtin:vim" relative_path = true url = "http://localhost:13337" - healthcheck{ + healthcheck { url = "http://localhost:13337/healthz" interval = 5 threshold = 6 + } } `, Check: func(state *terraform.State) error { From dc3771167ed9ce4e18ae9fd8e990ccbb83fb242f Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 21 Sep 2022 21:43:54 +0000 Subject: [PATCH 10/10] make gen --- docs/resources/app.md | 2 +- internal/provider/provider.go | 39 +++++++++++++----------------- internal/provider/provider_test.go | 3 --- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/docs/resources/app.md b/docs/resources/app.md index 9429e56f..cddc1fe8 100644 --- a/docs/resources/app.md +++ b/docs/resources/app.md @@ -76,7 +76,7 @@ resource "coder_app" "intellij" { ### Nested Schema for `healthcheck` -Optional: +Required: - `interval` (Number) Duration in seconds to wait between healthcheck requests. - `threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status. diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 17cb1b75..9caf6bf6 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -374,35 +374,30 @@ func New() *schema.Provider { ConflictsWith: []string{"command"}, }, "healthcheck": { - Type: schema.TypeSet, - Description: "HTTP health checking to determine the application readiness.", - ForceNew: true, - Optional: true, + Type: schema.TypeSet, + Description: "HTTP health checking to determine the application readiness.", + ForceNew: true, + Optional: true, + ConflictsWith: []string{"command"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "url": { - Type: schema.TypeString, - Description: "HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck.interval seconds.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - RequiredWith: []string{"healthcheck.interval", "healthcheck.threshold"}, + Type: schema.TypeString, + Description: "HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck.interval seconds.", + ForceNew: true, + Required: true, }, "interval": { - Type: schema.TypeInt, - Description: "Duration in seconds to wait between healthcheck requests.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - RequiredWith: []string{"healthcheck.url", "healthcheck.threshold"}, + Type: schema.TypeInt, + Description: "Duration in seconds to wait between healthcheck requests.", + ForceNew: true, + Required: true, }, "threshold": { - Type: schema.TypeInt, - Description: "Number of consecutive heathcheck failures before returning an unhealthy status.", - ForceNew: true, - Optional: true, - ConflictsWith: []string{"command"}, - RequiredWith: []string{"healthcheck.interval", "healthcheck.url"}, + Type: schema.TypeInt, + Description: "Number of consecutive heathcheck failures before returning an unhealthy status.", + ForceNew: true, + Required: true, }, }, }, diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 57cd3d5d..c9dc55e3 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -239,9 +239,6 @@ func TestApp(t *testing.T) { "icon", "relative_path", "url", - "healthcheck.url", - "healthcheck.interval", - "healthcheck.threshold", } { value := resource.Primary.Attributes[key] t.Logf("%q = %q", key, value)