From f14f186dba479dc49ff06f259773b2726f81e939 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Mon, 14 Aug 2023 22:13:21 +0000 Subject: [PATCH 01/10] feat: add default_apps field to agent - Enables a template admin to configure which apps are displayed to the user in the dashboard. --- docs/resources/agent.md | 1 + provider/agent.go | 9 ++++++++ provider/agent_test.go | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index d073f7c5..f13a63f9 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -48,6 +48,7 @@ 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. +- `default_apps` (List of String) The list of built-in apps to display in the UI. Defaults to all apps. - `dir` (String) The starting directory when a user creates a shell session. Defaults to $HOME. - `env` (Map of String) A mapping of environment variables to set inside the workspace. - `login_before_ready` (Boolean, Deprecated) 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. diff --git a/provider/agent.go b/provider/agent.go index 90dd0525..7f24d70a 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -198,6 +198,15 @@ func agentResource() *schema.Resource { }, }, }, + "default_apps": { + Type: schema.TypeList, + Description: "The list of built-in apps to display in the UI. Defaults to all apps.", + ForceNew: true, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, }, } } diff --git a/provider/agent_test.go b/provider/agent_test.go index e3d96d1b..4420858b 100644 --- a/provider/agent_test.go +++ b/provider/agent_test.go @@ -1,6 +1,7 @@ package provider_test import ( + "fmt" "regexp" "testing" @@ -247,3 +248,49 @@ func TestAgent_Metadata(t *testing.T) { }}, }) } + +func TestAgent_DefaultApps(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), + }, + IsUnitTest: true, + Steps: []resource.TestStep{{ + Config: ` + provider "coder" { + url = "https://example.com" + } + resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + default_apps = ["web-terminal", "vscode-desktop", "code-server", "port-forward"] + } + `, + Check: func(state *terraform.State) error { + require.Len(t, state.Modules, 1) + require.Len(t, state.Modules[0].Resources, 1) + + resource := state.Modules[0].Resources["coder_agent.dev"] + require.NotNil(t, resource) + + t.Logf("resource: %v", resource.Primary.Attributes) + + numElements, ok := resource.Primary.Attributes["default_apps.#"] + require.True(t, ok) + require.Equal(t, "4", numElements) + + for i, app := range []string{ + "web-terminal", + "vscode-desktop", + "code-server", + "port-forward", + } { + key := fmt.Sprintf("default_apps.%d", i) + require.Equal(t, resource.Primary.Attributes[key], app) + } + return nil + }, + }}, + }) +} From 63548638b744017cbb5bc499fe75ce9ae340ad99 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 23 Aug 2023 01:10:15 +0000 Subject: [PATCH 02/10] update structure of display_apps --- provider/agent.go | 83 +++++++++++++++++++-- provider/agent_test.go | 164 ++++++++++++++++++++++++++++++++++------- provider/workspace.go | 2 +- 3 files changed, 213 insertions(+), 36 deletions(-) diff --git a/provider/agent.go b/provider/agent.go index 7f24d70a..0745d918 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -23,6 +23,22 @@ func agentResource() *schema.Resource { if err != nil { return diag.FromErr(err) } + + if _, ok := resourceData.GetOk("display_apps"); !ok { + err = resourceData.Set("display_apps", []interface{}{ + map[string]bool{ + "vscode": true, + "vscode_insiders": false, + "web_terminal": true, + "ssh_helper": true, + "port_forwarding_helper": true, + }, + }) + if err != nil { + return diag.FromErr(err) + } + } + return updateInitScript(resourceData, i) }, ReadWithoutTimeout: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { @@ -30,6 +46,21 @@ func agentResource() *schema.Resource { if err != nil { return diag.FromErr(err) } + if _, ok := resourceData.GetOk("display_apps"); !ok { + err = resourceData.Set("display_apps", []interface{}{ + map[string]bool{ + "vscode": true, + "vscode_insiders": false, + "web_terminal": true, + "ssh_helper": true, + "port_forwarding_helper": true, + }, + }) + if err != nil { + return diag.FromErr(err) + } + } + return updateInitScript(resourceData, i) }, DeleteContext: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { @@ -198,13 +229,51 @@ func agentResource() *schema.Resource { }, }, }, - "default_apps": { - Type: schema.TypeList, - Description: "The list of built-in apps to display in the UI. Defaults to all apps.", - ForceNew: true, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + "display_apps": { + Type: schema.TypeSet, + Description: "The list of built-in apps to display in the agent bar.", + ForceNew: true, + Optional: true, + MaxItems: 1, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vscode": { + Type: schema.TypeBool, + Description: "Display the VSCode Desktop app in the agent bar.", + ForceNew: true, + Optional: true, + Default: true, + }, + "vscode_insiders": { + Type: schema.TypeBool, + Description: "Display the VSCode Insiders app in the agent bar.", + ForceNew: true, + Optional: true, + Default: false, + }, + "web_terminal": { + Type: schema.TypeBool, + Description: "Display the web terminal app in the agent bar.", + ForceNew: true, + Optional: true, + Default: true, + }, + "port_forwarding_helper": { + Type: schema.TypeBool, + Description: "Display port-forwarding helper button in the agent bar.", + ForceNew: true, + Optional: true, + Default: true, + }, + "ssh_helper": { + Type: schema.TypeBool, + Description: "Display port-forwarding helper button in the agent bar.", + ForceNew: true, + Optional: true, + Default: true, + }, + }, }, }, }, diff --git a/provider/agent_test.go b/provider/agent_test.go index 4420858b..c46bc21c 100644 --- a/provider/agent_test.go +++ b/provider/agent_test.go @@ -251,46 +251,154 @@ func TestAgent_Metadata(t *testing.T) { func TestAgent_DefaultApps(t *testing.T) { t.Parallel() - resource.Test(t, resource.TestCase{ - Providers: map[string]*schema.Provider{ - "coder": provider.New(), - }, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: ` + t.Run("OK", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), + }, + IsUnitTest: true, + Steps: []resource.TestStep{{ + // Test the fields with non-default values. + Config: ` provider "coder" { url = "https://example.com" } resource "coder_agent" "dev" { os = "linux" arch = "amd64" - default_apps = ["web-terminal", "vscode-desktop", "code-server", "port-forward"] + display_apps { + vscode = false + vscode_insiders = true + web_terminal = false + port_forwarding_helper = false + ssh_helper = false + } } `, - Check: func(state *terraform.State) error { - require.Len(t, state.Modules, 1) - require.Len(t, state.Modules[0].Resources, 1) + Check: func(state *terraform.State) error { + require.Len(t, state.Modules, 1) + require.Len(t, state.Modules[0].Resources, 1) - resource := state.Modules[0].Resources["coder_agent.dev"] - require.NotNil(t, resource) + resource := state.Modules[0].Resources["coder_agent.dev"] + require.NotNil(t, resource) - t.Logf("resource: %v", resource.Primary.Attributes) + t.Logf("resource: %v", resource.Primary.Attributes) - numElements, ok := resource.Primary.Attributes["default_apps.#"] - require.True(t, ok) - require.Equal(t, "4", numElements) + for _, app := range []string{ + "web_terminal", + "vscode_insiders", + "vscode", + "port_forwarding_helper", + "ssh_helper", + } { + key := fmt.Sprintf("display_apps.0.%s", app) + if app == "vscode_insiders" { + require.Equal(t, "true", resource.Primary.Attributes[key]) + } else { + require.Equal(t, "false", resource.Primary.Attributes[key]) + } + } + return nil + }, + }}, + }) - for i, app := range []string{ - "web-terminal", - "vscode-desktop", - "code-server", - "port-forward", - } { - key := fmt.Sprintf("default_apps.%d", i) - require.Equal(t, resource.Primary.Attributes[key], app) - } - return nil + }) + + // Assert all the defaults are set correctly. + t.Run("Omitted", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), }, - }}, + IsUnitTest: true, + Steps: []resource.TestStep{{ + Config: ` + provider "coder" { + url = "https://example.com" + } + resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + } + `, + Check: func(state *terraform.State) error { + require.Len(t, state.Modules, 1) + require.Len(t, state.Modules[0].Resources, 1) + + resource := state.Modules[0].Resources["coder_agent.dev"] + require.NotNil(t, resource) + + t.Logf("resource: %v", resource.Primary.Attributes) + + for _, app := range []string{ + "web_terminal", + "vscode_insiders", + "vscode", + "port_forwarding_helper", + "ssh_helper", + } { + key := fmt.Sprintf("display_apps.0.%s", app) + if app == "vscode_insiders" { + require.Equal(t, "false", resource.Primary.Attributes[key]) + } else { + require.Equal(t, "true", resource.Primary.Attributes[key]) + } + } + return nil + }, + }}, + }) + }) + + t.Run("Empty", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), + }, + IsUnitTest: true, + Steps: []resource.TestStep{{ + Config: ` + provider "coder" { + url = "https://example.com" + } + resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + display_apps { + vscode = false + } + } + `, + Check: func(state *terraform.State) error { + require.Len(t, state.Modules, 1) + require.Len(t, state.Modules[0].Resources, 1) + + resource := state.Modules[0].Resources["coder_agent.dev"] + require.NotNil(t, resource) + + t.Logf("resource: %v", resource.Primary.Attributes) + + for _, app := range []string{ + "web_terminal", + "vscode_insiders", + "vscode", + "port_forwarding_helper", + "ssh_helper", + } { + key := fmt.Sprintf("display_apps.0.%s", app) + if app == "vscode_insiders" { + require.Equal(t, "false", resource.Primary.Attributes[key]) + } else { + require.Equal(t, "true", resource.Primary.Attributes[key]) + } + } + + return nil + }, + }}, + }) + }) + } diff --git a/provider/workspace.go b/provider/workspace.go index 47f0e799..995cb6e4 100644 --- a/provider/workspace.go +++ b/provider/workspace.go @@ -137,7 +137,7 @@ func workspaceDataSource() *schema.Resource { "owner_session_token": { Type: schema.TypeString, Computed: true, - Description: "Session token for interfacing with a Coder deployment. It is regenerated everytime a workspace is started.", + Description: "Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.", }, }, } From c5261791f3ea55f56f92418f4b13af356c94e6ec Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 23 Aug 2023 01:10:50 +0000 Subject: [PATCH 03/10] make geN --- docs/data-sources/workspace.md | 2 +- docs/resources/agent.md | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/data-sources/workspace.md b/docs/data-sources/workspace.md index e7d58a5d..c736f78a 100644 --- a/docs/data-sources/workspace.md +++ b/docs/data-sources/workspace.md @@ -34,6 +34,6 @@ resource "kubernetes_pod" "dev" { - `owner_email` (String) Email address of the workspace owner. - `owner_id` (String) UUID of the workspace owner. - `owner_oidc_access_token` (String) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string. -- `owner_session_token` (String) Session token for interfacing with a Coder deployment. It is regenerated everytime a workspace is started. +- `owner_session_token` (String) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started. - `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1. - `transition` (String) Either "start" or "stop". Use this to start/stop resources with "count". diff --git a/docs/resources/agent.md b/docs/resources/agent.md index f13a63f9..00c59e1f 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -48,8 +48,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. -- `default_apps` (List of String) The list of built-in apps to display in the UI. Defaults to all apps. - `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) 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)) @@ -67,6 +67,18 @@ resource "kubernetes_pod" "dev" { - `init_script` (String) Run this script on startup of an instance to initialize the agent. - `token` (String, Sensitive) Set the environment variable "CODER_AGENT_TOKEN" with this token to authenticate an agent. + +### Nested Schema for `display_apps` + +Optional: + +- `port_forwarding_helper` (Boolean) Display port-forwarding helper button in the agent bar. +- `ssh_helper` (Boolean) Display port-forwarding helper button in the agent bar. +- `vscode` (Boolean) Display the VSCode Desktop app in the agent bar. +- `vscode_insiders` (Boolean) Display the VSCode Insiders app in the agent bar. +- `web_terminal` (Boolean) Display the web terminal app in the agent bar. + + ### Nested Schema for `metadata` From 41f4ebd2396a7f95ecc29c257431e41092cb5890 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 23 Aug 2023 01:14:59 +0000 Subject: [PATCH 04/10] rm bad test --- provider/agent_test.go | 51 ------------------------------------------ 1 file changed, 51 deletions(-) diff --git a/provider/agent_test.go b/provider/agent_test.go index c46bc21c..0afe8981 100644 --- a/provider/agent_test.go +++ b/provider/agent_test.go @@ -350,55 +350,4 @@ func TestAgent_DefaultApps(t *testing.T) { }}, }) }) - - t.Run("Empty", func(t *testing.T) { - resource.Test(t, resource.TestCase{ - Providers: map[string]*schema.Provider{ - "coder": provider.New(), - }, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: ` - provider "coder" { - url = "https://example.com" - } - resource "coder_agent" "dev" { - os = "linux" - arch = "amd64" - display_apps { - vscode = false - } - } - `, - Check: func(state *terraform.State) error { - require.Len(t, state.Modules, 1) - require.Len(t, state.Modules[0].Resources, 1) - - resource := state.Modules[0].Resources["coder_agent.dev"] - require.NotNil(t, resource) - - t.Logf("resource: %v", resource.Primary.Attributes) - - for _, app := range []string{ - "web_terminal", - "vscode_insiders", - "vscode", - "port_forwarding_helper", - "ssh_helper", - } { - key := fmt.Sprintf("display_apps.0.%s", app) - if app == "vscode_insiders" { - require.Equal(t, "false", resource.Primary.Attributes[key]) - } else { - require.Equal(t, "true", resource.Primary.Attributes[key]) - } - } - - return nil - }, - }}, - }) - - }) - } From ce6fd70c59a430cb935f28dc781d3388e090617d Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Tue, 29 Aug 2023 23:35:43 +0000 Subject: [PATCH 05/10] add example --- examples/resources/coder_agent/resource.tf | 6 ++ provider/agent.go | 1 - provider/agent_test.go | 80 +++++++++++++++++++++- provider/examples_test.go | 15 +++- 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/examples/resources/coder_agent/resource.tf b/examples/resources/coder_agent/resource.tf index 2f1503fd..b57d421f 100644 --- a/examples/resources/coder_agent/resource.tf +++ b/examples/resources/coder_agent/resource.tf @@ -5,6 +5,12 @@ resource "coder_agent" "dev" { os = "linux" arch = "amd64" dir = "/workspace" + display_apps { + vscode = true + vscode_insiders = false + web_terminal = true + ssh_helper = false + } } resource "kubernetes_pod" "dev" { diff --git a/provider/agent.go b/provider/agent.go index 0745d918..604782bb 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -38,7 +38,6 @@ func agentResource() *schema.Resource { return diag.FromErr(err) } } - return updateInitScript(resourceData, i) }, ReadWithoutTimeout: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { diff --git a/provider/agent_test.go b/provider/agent_test.go index 0afe8981..9026385c 100644 --- a/provider/agent_test.go +++ b/provider/agent_test.go @@ -5,11 +5,12 @@ import ( "regexp" "testing" - "github.com/coder/terraform-provider-coder/provider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/stretchr/testify/require" + + "github.com/coder/terraform-provider-coder/provider" ) func TestAgent(t *testing.T) { @@ -249,7 +250,7 @@ func TestAgent_Metadata(t *testing.T) { }) } -func TestAgent_DefaultApps(t *testing.T) { +func TestAgent_DisplayApps(t *testing.T) { t.Parallel() t.Run("OK", func(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -302,7 +303,52 @@ func TestAgent_DefaultApps(t *testing.T) { }, }}, }) + }) + + t.Run("Subset", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), + }, + IsUnitTest: true, + Steps: []resource.TestStep{{ + // Test the fields with non-default values. + Config: ` + provider "coder" { + url = "https://example.com" + } + resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + display_apps { + vscode_insiders = true + web_terminal = true + } + } + `, + Check: func(state *terraform.State) error { + require.Len(t, state.Modules, 1) + require.Len(t, state.Modules[0].Resources, 1) + resource := state.Modules[0].Resources["coder_agent.dev"] + require.NotNil(t, resource) + + t.Logf("resource: %v", resource.Primary.Attributes) + + for _, app := range []string{ + "web_terminal", + "vscode_insiders", + "vscode", + "port_forwarding_helper", + "ssh_helper", + } { + key := fmt.Sprintf("display_apps.0.%s", app) + require.Equal(t, "true", resource.Primary.Attributes[key]) + } + return nil + }, + }}, + }) }) // Assert all the defaults are set correctly. @@ -350,4 +396,34 @@ func TestAgent_DefaultApps(t *testing.T) { }}, }) }) + + t.Run("InvalidApp", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), + }, + IsUnitTest: true, + Steps: []resource.TestStep{{ + // Test the fields with non-default values. + Config: ` + provider "coder" { + url = "https://example.com" + } + resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + display_apps { + fake_app = false + vscode_insiders = true + web_terminal = false + port_forwarding_helper = false + ssh_helper = false + } + } + `, + ExpectError: regexp.MustCompile(`An argument named "fake_app" is not expected here.`), + }}, + }) + }) + } diff --git a/provider/examples_test.go b/provider/examples_test.go index 263e65ce..f2f6e3bb 100644 --- a/provider/examples_test.go +++ b/provider/examples_test.go @@ -4,15 +4,28 @@ import ( "os" "testing" - "github.com/coder/terraform-provider-coder/provider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/require" + + "github.com/coder/terraform-provider-coder/provider" ) func TestExamples(t *testing.T) { t.Parallel() + t.Run("coder_agent", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "coder": provider.New(), + }, + IsUnitTest: true, + Steps: []resource.TestStep{{ + Config: mustReadFile(t, "../examples/resources/coder_parameter/resource.tf"), + }}, + }) + }) + t.Run("coder_parameter", func(t *testing.T) { t.Parallel() From 018a016baa0a160240184e998949e5e796ff900d Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Tue, 29 Aug 2023 23:37:10 +0000 Subject: [PATCH 06/10] fix documentation --- provider/agent.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provider/agent.go b/provider/agent.go index 604782bb..9b5ac3f3 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -260,14 +260,14 @@ func agentResource() *schema.Resource { }, "port_forwarding_helper": { Type: schema.TypeBool, - Description: "Display port-forwarding helper button in the agent bar.", + Description: "Display the port-forwarding helper button in the agent bar.", ForceNew: true, Optional: true, Default: true, }, "ssh_helper": { Type: schema.TypeBool, - Description: "Display port-forwarding helper button in the agent bar.", + Description: "Display the SSH helper button in the agent bar.", ForceNew: true, Optional: true, Default: true, From 2486658bf40fedf1205e58568173484034e1fce7 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Tue, 29 Aug 2023 23:38:46 +0000 Subject: [PATCH 07/10] make gen --- docs/resources/agent.md | 10 ++++++++-- examples/resources/coder_agent/resource.tf | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index 00c59e1f..7e20ade4 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -20,6 +20,12 @@ resource "coder_agent" "dev" { os = "linux" arch = "amd64" dir = "/workspace" + display_apps { + vscode = true + vscode_insiders = false + web_terminal = true + ssh_helper = false + } } resource "kubernetes_pod" "dev" { @@ -72,8 +78,8 @@ resource "kubernetes_pod" "dev" { Optional: -- `port_forwarding_helper` (Boolean) Display port-forwarding helper button in the agent bar. -- `ssh_helper` (Boolean) Display port-forwarding helper button in the agent bar. +- `port_forwarding_helper` (Boolean) Display the port-forwarding helper button in the agent bar. +- `ssh_helper` (Boolean) Display the SSH helper button in the agent bar. - `vscode` (Boolean) Display the VSCode Desktop app in the agent bar. - `vscode_insiders` (Boolean) Display the VSCode Insiders app in the agent bar. - `web_terminal` (Boolean) Display the web terminal app in the agent bar. diff --git a/examples/resources/coder_agent/resource.tf b/examples/resources/coder_agent/resource.tf index b57d421f..d5235a18 100644 --- a/examples/resources/coder_agent/resource.tf +++ b/examples/resources/coder_agent/resource.tf @@ -6,10 +6,10 @@ resource "coder_agent" "dev" { arch = "amd64" dir = "/workspace" display_apps { - vscode = true - vscode_insiders = false - web_terminal = true - ssh_helper = false + vscode = true + vscode_insiders = false + web_terminal = true + ssh_helper = false } } From 3d29895581dc4c135a8fd390932efead8ccb8d7e Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 30 Aug 2023 18:56:34 +0000 Subject: [PATCH 08/10] update example --- examples/resources/coder_agent/resource.tf | 13 ------------- provider/examples_test.go | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/examples/resources/coder_agent/resource.tf b/examples/resources/coder_agent/resource.tf index d5235a18..368dd133 100644 --- a/examples/resources/coder_agent/resource.tf +++ b/examples/resources/coder_agent/resource.tf @@ -12,16 +12,3 @@ resource "coder_agent" "dev" { ssh_helper = false } } - -resource "kubernetes_pod" "dev" { - count = data.coder_workspace.me.start_count - spec { - container { - command = ["sh", "-c", coder_agent.dev.init_script] - env { - name = "CODER_AGENT_TOKEN" - value = coder_agent.dev.token - } - } - } -} diff --git a/provider/examples_test.go b/provider/examples_test.go index f2f6e3bb..52d84ccf 100644 --- a/provider/examples_test.go +++ b/provider/examples_test.go @@ -21,7 +21,7 @@ func TestExamples(t *testing.T) { }, IsUnitTest: true, Steps: []resource.TestStep{{ - Config: mustReadFile(t, "../examples/resources/coder_parameter/resource.tf"), + Config: mustReadFile(t, "../examples/resources/coder_agent/resource.tf"), }}, }) }) From 6daeca74921e72ee0b71cbf1f3c833edde68d040 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 30 Aug 2023 18:57:11 +0000 Subject: [PATCH 09/10] update example --- docs/resources/agent.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index 7e20ade4..50dee91f 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -27,19 +27,6 @@ resource "coder_agent" "dev" { ssh_helper = false } } - -resource "kubernetes_pod" "dev" { - count = data.coder_workspace.me.start_count - spec { - container { - command = ["sh", "-c", coder_agent.dev.init_script] - env { - name = "CODER_AGENT_TOKEN" - value = coder_agent.dev.token - } - } - } -} ``` From aafdee427569571fa155b45ca230488ccf754cee Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 30 Aug 2023 18:59:29 +0000 Subject: [PATCH 10/10] remove bad test --- docs/resources/agent.md | 13 +++++++++++++ examples/resources/coder_agent/resource.tf | 13 +++++++++++++ provider/examples_test.go | 12 ------------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index 50dee91f..7e20ade4 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -27,6 +27,19 @@ resource "coder_agent" "dev" { ssh_helper = false } } + +resource "kubernetes_pod" "dev" { + count = data.coder_workspace.me.start_count + spec { + container { + command = ["sh", "-c", coder_agent.dev.init_script] + env { + name = "CODER_AGENT_TOKEN" + value = coder_agent.dev.token + } + } + } +} ``` diff --git a/examples/resources/coder_agent/resource.tf b/examples/resources/coder_agent/resource.tf index 368dd133..d5235a18 100644 --- a/examples/resources/coder_agent/resource.tf +++ b/examples/resources/coder_agent/resource.tf @@ -12,3 +12,16 @@ resource "coder_agent" "dev" { ssh_helper = false } } + +resource "kubernetes_pod" "dev" { + count = data.coder_workspace.me.start_count + spec { + container { + command = ["sh", "-c", coder_agent.dev.init_script] + env { + name = "CODER_AGENT_TOKEN" + value = coder_agent.dev.token + } + } + } +} diff --git a/provider/examples_test.go b/provider/examples_test.go index 52d84ccf..9be7ce02 100644 --- a/provider/examples_test.go +++ b/provider/examples_test.go @@ -14,18 +14,6 @@ import ( func TestExamples(t *testing.T) { t.Parallel() - t.Run("coder_agent", func(t *testing.T) { - resource.Test(t, resource.TestCase{ - Providers: map[string]*schema.Provider{ - "coder": provider.New(), - }, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: mustReadFile(t, "../examples/resources/coder_agent/resource.tf"), - }}, - }) - }) - t.Run("coder_parameter", func(t *testing.T) { t.Parallel()