Skip to content

Commit

Permalink
Change cmd to string array
Browse files Browse the repository at this point in the history
  • Loading branch information
ammario committed Mar 15, 2023
1 parent 6a06f8f commit 208a014
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/resources/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "kubernetes_pod" "dev" {

Required:

- `cmd` (String) The command that retrieves the value of this metadata item.
- `cmd` (List of String) The command that retrieves the value of this metadata item.
- `interval` (Number) The interval in seconds at which to refresh this metadata item.
- `key` (String) The key of this metadata item.

Expand Down
5 changes: 4 additions & 1 deletion provider/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,13 @@ func agentResource() *schema.Resource {
Optional: true,
},
"cmd": {
Type: schema.TypeString,
Type: schema.TypeList,
Description: "The command that retrieves the value of this metadata item.",
ForceNew: true,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"interval": {
Type: schema.TypeInt,
Expand Down
7 changes: 5 additions & 2 deletions provider/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestAgent_Metadata(t *testing.T) {
metadata {
key = "process_count"
display_name = "Process Count"
cmd = "ps aux | wc -l"
cmd = ["sh", "-c", "ps aux | wc -l"]
interval = 5
}
}
Expand All @@ -148,7 +148,10 @@ func TestAgent_Metadata(t *testing.T) {
require.Equal(t, "1", attr["metadata.#"])
require.Equal(t, "process_count", attr["metadata.0.key"])
require.Equal(t, "Process Count", attr["metadata.0.display_name"])
require.Equal(t, "ps aux | wc -l", attr["metadata.0.cmd"])
require.Equal(t, "3", attr["metadata.0.cmd.#"])
require.Equal(t, "sh", attr["metadata.0.cmd.0"])
require.Equal(t, "-c", attr["metadata.0.cmd.1"])
require.Equal(t, "ps aux | wc -l", attr["metadata.0.cmd.2"])
require.Equal(t, "5", attr["metadata.0.interval"])
return nil
},
Expand Down

0 comments on commit 208a014

Please sign in to comment.