Skip to content

Commit 7458fc0

Browse files
authored
feat: add order property to agent_metadata (#187)
1 parent 56cf845 commit 7458fc0

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

Diff for: docs/resources/agent.md

+18
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ resource "coder_agent" "dev" {
2626
web_terminal = true
2727
ssh_helper = false
2828
}
29+
30+
metadata {
31+
display_name = "CPU Usage"
32+
key = "cpu_usage"
33+
script = "coder stat cpu"
34+
interval = 10
35+
timeout = 1
36+
order = 2
37+
}
38+
metadata {
39+
display_name = "RAM Usage"
40+
key = "ram_usage"
41+
script = "coder stat mem"
42+
interval = 10
43+
timeout = 1
44+
order = 1
45+
}
2946
}
3047
3148
resource "kubernetes_pod" "dev" {
@@ -97,4 +114,5 @@ Required:
97114
Optional:
98115

99116
- `display_name` (String) The user-facing name of this value.
117+
- `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).
100118
- `timeout` (Number) The maximum time the command is allowed to run in seconds.

Diff for: examples/resources/coder_agent/resource.tf

+17
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" {

Diff for: provider/agent.go

+5
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
},

Diff for: provider/agent_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ func TestAgent_Metadata(t *testing.T) {
225225
script = "ps aux | wc -l"
226226
interval = 5
227227
timeout = 1
228+
order = 7
228229
}
229230
}
230231
`,
@@ -244,6 +245,7 @@ func TestAgent_Metadata(t *testing.T) {
244245
require.Equal(t, "ps aux | wc -l", attr["metadata.0.script"])
245246
require.Equal(t, "5", attr["metadata.0.interval"])
246247
require.Equal(t, "1", attr["metadata.0.timeout"])
248+
require.Equal(t, "7", attr["metadata.0.order"])
247249
return nil
248250
},
249251
}},

0 commit comments

Comments
 (0)