Skip to content

Commit

Permalink
feat: add order property to agent_metadata (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtojek authored Feb 7, 2024
1 parent 56cf845 commit 7458fc0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/resources/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ resource "coder_agent" "dev" {
web_terminal = true
ssh_helper = false
}
metadata {
display_name = "CPU Usage"
key = "cpu_usage"
script = "coder stat cpu"
interval = 10
timeout = 1
order = 2
}
metadata {
display_name = "RAM Usage"
key = "ram_usage"
script = "coder stat mem"
interval = 10
timeout = 1
order = 1
}
}
resource "kubernetes_pod" "dev" {
Expand Down Expand Up @@ -97,4 +114,5 @@ Required:
Optional:

- `display_name` (String) The user-facing name of this value.
- `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).
- `timeout` (Number) The maximum time the command is allowed to run in seconds.
17 changes: 17 additions & 0 deletions examples/resources/coder_agent/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ resource "coder_agent" "dev" {
web_terminal = true
ssh_helper = false
}

metadata {
display_name = "CPU Usage"
key = "cpu_usage"
script = "coder stat cpu"
interval = 10
timeout = 1
order = 2
}
metadata {
display_name = "RAM Usage"
key = "ram_usage"
script = "coder stat mem"
interval = 10
timeout = 1
order = 1
}
}

resource "kubernetes_pod" "dev" {
Expand Down
5 changes: 5 additions & 0 deletions provider/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ func agentResource() *schema.Resource {
ForceNew: true,
Required: true,
},
"order": {
Type: schema.TypeInt,
Optional: true,
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).",
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions provider/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func TestAgent_Metadata(t *testing.T) {
script = "ps aux | wc -l"
interval = 5
timeout = 1
order = 7
}
}
`,
Expand All @@ -244,6 +245,7 @@ func TestAgent_Metadata(t *testing.T) {
require.Equal(t, "ps aux | wc -l", attr["metadata.0.script"])
require.Equal(t, "5", attr["metadata.0.interval"])
require.Equal(t, "1", attr["metadata.0.timeout"])
require.Equal(t, "7", attr["metadata.0.order"])
return nil
},
}},
Expand Down

0 comments on commit 7458fc0

Please sign in to comment.