Skip to content

Commit 779f999

Browse files
feat: Add icon to coder_metadata resource (#48)
1 parent 5718dbd commit 779f999

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

internal/provider/provider.go

+15
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,21 @@ func New() *schema.Provider {
406406
ForceNew: true,
407407
Optional: true,
408408
},
409+
"icon": {
410+
Type: schema.TypeString,
411+
Description: "A URL to an icon that will display in the dashboard. View built-in " +
412+
"icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a " +
413+
"built-in icon with `data.coder_workspace.me.access_url + \"/icons/<path>\"`.",
414+
ForceNew: true,
415+
Optional: true,
416+
ValidateFunc: func(i interface{}, s string) ([]string, []error) {
417+
_, err := url.Parse(s)
418+
if err != nil {
419+
return nil, []error{err}
420+
}
421+
return nil, nil
422+
},
423+
},
409424
"item": {
410425
Type: schema.TypeList,
411426
Description: "Each \"item\" block defines a single metadata item consisting of a key/value pair.",

internal/provider/provider_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func TestMetadata(t *testing.T) {
264264
resource "coder_metadata" "agent" {
265265
resource_id = coder_agent.dev.id
266266
hide = true
267+
icon = "/icons/storage.svg"
267268
item {
268269
key = "foo"
269270
value = "bar"
@@ -297,6 +298,7 @@ func TestMetadata(t *testing.T) {
297298
for key, expected := range map[string]string{
298299
"resource_id": agent.Primary.Attributes["id"],
299300
"hide": "true",
301+
"icon": "/icons/storage.svg",
300302
"item.#": "5",
301303
"item.0.key": "foo",
302304
"item.0.value": "bar",

0 commit comments

Comments
 (0)