Skip to content

Rename cost to daily_cost #75

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 2 commits into from
Nov 13, 2022
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
8 changes: 4 additions & 4 deletions docs/resources/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/<path>"`.
- `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

Expand Down
16 changes: 9 additions & 7 deletions provider/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions provider/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down