From 721fc57e9656126b8696816d8111f8670ed567f1 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 12 Nov 2022 21:47:21 +0000 Subject: [PATCH 1/2] Rename `cost` to `daily_cost` --- docs/resources/metadata.md | 4 ++-- provider/metadata.go | 14 ++++++++------ provider/metadata_test.go | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/resources/metadata.md b/docs/resources/metadata.md index 55731ba3..98d4c2b3 100644 --- a/docs/resources/metadata.md +++ b/docs/resources/metadata.md @@ -52,14 +52,14 @@ resource "coder_metadata" "pod_info" { ### Required -- `item` (Block List, Min: 1) Each "item" block defines a single metadata item consisting of a key/value pair. (see [below for nested schema](#nestedblock--item)) - `resource_id` (String) The "id" property of another resource that metadata should be attached to. ### Optional -- `cost` (Number) (Enterprise) The amount of quota units this resource consumes +- `daily_cost` (Number) (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents. - `hide` (Boolean) Hide the resource from the UI. - `icon` (String) 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/"`. +- `item` (Block List) Each "item" block defines a single metadata item consisting of a key/value pair. (see [below for nested schema](#nestedblock--item)) ### Read-Only diff --git a/provider/metadata.go b/provider/metadata.go index 40b392d2..24f8ab1e 100644 --- a/provider/metadata.go +++ b/provider/metadata.go @@ -61,17 +61,19 @@ func metadataResource() *schema.Resource { return nil, nil }, }, - "cost": { - Type: schema.TypeInt, - Description: "(Enterprise) The amount of quota units this resource consumes", - ForceNew: true, - Optional: true, + "daily_cost": { + Type: schema.TypeInt, + Description: "(Enterprise) The cost of this resource every 24 hours." + + " Use the smallest denomination of your preferred currency." + + " For example, if you work in USD, use cents.", + ForceNew: true, + Optional: true, }, "item": { Type: schema.TypeList, Description: "Each \"item\" block defines a single metadata item consisting of a key/value pair.", ForceNew: true, - Required: true, + Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "key": { diff --git a/provider/metadata_test.go b/provider/metadata_test.go index 83d93cc7..cb9e801c 100644 --- a/provider/metadata_test.go +++ b/provider/metadata_test.go @@ -31,7 +31,7 @@ func TestMetadata(t *testing.T) { resource_id = coder_agent.dev.id hide = true icon = "/icons/storage.svg" - cost = 200 + daily_cost = 200 item { key = "foo" value = "bar" @@ -66,7 +66,7 @@ func TestMetadata(t *testing.T) { "resource_id": agent.Primary.Attributes["id"], "hide": "true", "icon": "/icons/storage.svg", - "cost": "200", + "daily_cost": "200", "item.#": "5", "item.0.key": "foo", "item.0.value": "bar", From 3652ff0951833121b679eb795eaa517f749a1179 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 12 Nov 2022 21:49:13 +0000 Subject: [PATCH 2/2] fixup! Rename `cost` to `daily_cost` --- docs/resources/metadata.md | 4 ++-- provider/metadata.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/resources/metadata.md b/docs/resources/metadata.md index 98d4c2b3..0c6d068d 100644 --- a/docs/resources/metadata.md +++ b/docs/resources/metadata.md @@ -3,12 +3,12 @@ page_title: "coder_metadata Resource - terraform-provider-coder" subcategory: "" description: |- - Use this resource to attach key/value pairs to a resource. They will be displayed in the Coder dashboard. + Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard. --- # coder_metadata (Resource) -Use this resource to attach key/value pairs to a resource. They will be displayed in the Coder dashboard. +Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard. ## Example Usage diff --git a/provider/metadata.go b/provider/metadata.go index 24f8ab1e..56af9dd4 100644 --- a/provider/metadata.go +++ b/provider/metadata.go @@ -11,7 +11,7 @@ import ( func metadataResource() *schema.Resource { return &schema.Resource{ - Description: "Use this resource to attach key/value pairs to a resource. They will be " + + Description: "Use this resource to attach metadata to a resource. They will be " + "displayed in the Coder dashboard.", CreateContext: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { resourceData.SetId(uuid.NewString())