Skip to content

Commit

Permalink
feat: Add icon to coder_metadata resource (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoQuaresma authored Sep 12, 2022
1 parent 5718dbd commit 779f999
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,21 @@ func New() *schema.Provider {
ForceNew: true,
Optional: true,
},
"icon": {
Type: schema.TypeString,
Description: "A URL to an icon that will display in the dashboard. View built-in " +
"icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a " +
"built-in icon with `data.coder_workspace.me.access_url + \"/icons/<path>\"`.",
ForceNew: true,
Optional: true,
ValidateFunc: func(i interface{}, s string) ([]string, []error) {
_, err := url.Parse(s)
if err != nil {
return nil, []error{err}
}
return nil, nil
},
},
"item": {
Type: schema.TypeList,
Description: "Each \"item\" block defines a single metadata item consisting of a key/value pair.",
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func TestMetadata(t *testing.T) {
resource "coder_metadata" "agent" {
resource_id = coder_agent.dev.id
hide = true
icon = "/icons/storage.svg"
item {
key = "foo"
value = "bar"
Expand Down Expand Up @@ -297,6 +298,7 @@ func TestMetadata(t *testing.T) {
for key, expected := range map[string]string{
"resource_id": agent.Primary.Attributes["id"],
"hide": "true",
"icon": "/icons/storage.svg",
"item.#": "5",
"item.0.key": "foo",
"item.0.value": "bar",
Expand Down

0 comments on commit 779f999

Please sign in to comment.