Skip to content

Commit cb4b8cf

Browse files
committed
feat: add order property to agent_metadata
1 parent 56cf845 commit cb4b8cf

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

docs/resources/agent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,5 @@ Required:
9797
Optional:
9898

9999
- `display_name` (String) The user-facing name of this value.
100+
- `order` (Number) The order determines the position of agent metadata in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by key (ascending order).
100101
- `timeout` (Number) The maximum time the command is allowed to run in seconds.

examples/resources/coder_agent/resource.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ resource "coder_agent" "dev" {
1111
web_terminal = true
1212
ssh_helper = false
1313
}
14+
15+
metadata {
16+
display_name = "CPU Usage"
17+
key = "cpu_usage"
18+
script = "coder stat cpu"
19+
interval = 10
20+
timeout = 1
21+
order = 2
22+
}
23+
metadata {
24+
display_name = "RAM Usage"
25+
key = "ram_usage"
26+
script = "coder stat mem"
27+
interval = 10
28+
timeout = 1
29+
order = 1
30+
}
1431
}
1532

1633
resource "kubernetes_pod" "dev" {

provider/agent.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ func agentResource() *schema.Resource {
239239
ForceNew: true,
240240
Required: true,
241241
},
242+
"order": {
243+
Type: schema.TypeInt,
244+
Optional: true,
245+
Description: "The order determines the position of agent metadata in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by key (ascending order).",
246+
},
242247
},
243248
},
244249
},

provider/agent_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestAgent(t *testing.T) {
3939
motd_file = "/etc/motd"
4040
shutdown_script = "echo bye bye"
4141
shutdown_script_timeout = 120
42+
order = 7
4243
}
4344
`,
4445
Check: func(state *terraform.State) error {
@@ -60,6 +61,7 @@ func TestAgent(t *testing.T) {
6061
"motd_file",
6162
"shutdown_script",
6263
"shutdown_script_timeout",
64+
"order",
6365
} {
6466
value := resource.Primary.Attributes[key]
6567
t.Logf("%q = %q", key, value)

0 commit comments

Comments
 (0)