From 7815596401d6e69aebb4ceefe1e84369cb63c4ac Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 13 Feb 2024 11:43:12 +0100 Subject: [PATCH] feat: Add `order` to `coder_agent` (#193) --- docs/resources/agent.md | 1 + provider/agent.go | 6 ++++++ provider/agent_test.go | 2 ++ 3 files changed, 9 insertions(+) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index 23966105..68963947 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -79,6 +79,7 @@ resource "kubernetes_pod" "dev" { - `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)) - `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) 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. diff --git a/provider/agent.go b/provider/agent.go index f02462a8..7b197870 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -297,6 +297,12 @@ func agentResource() *schema.Resource { }, }, }, + "order": { + Type: schema.TypeInt, + Description: "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).", + ForceNew: true, + Optional: true, + }, }, } } diff --git a/provider/agent_test.go b/provider/agent_test.go index f70a7f90..491e59f9 100644 --- a/provider/agent_test.go +++ b/provider/agent_test.go @@ -39,6 +39,7 @@ func TestAgent(t *testing.T) { motd_file = "/etc/motd" shutdown_script = "echo bye bye" shutdown_script_timeout = 120 + order = 4 } `, Check: func(state *terraform.State) error { @@ -60,6 +61,7 @@ func TestAgent(t *testing.T) { "motd_file", "shutdown_script", "shutdown_script_timeout", + "order", } { value := resource.Primary.Attributes[key] t.Logf("%q = %q", key, value)