Skip to content

feat: add order property to agent_metadata #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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