Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions provider/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func metadataResource() *schema.Resource {
ForceNew: true,
Computed: true,
},
"order": {
Type: schema.TypeInt,
Description: "The order determines the position of item in the UI presentation. The lowest order is shown first and items with equal order are sorted by key (ascending order).",
ForceNew: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... is ForceNew necessary @johnstcn ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, but it is already used in agent.metadata.order so it may be no harm to be safe and stick to the status quo.

Optional: true,
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions provider/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestMetadata(t *testing.T) {
item {
key = "foo"
value = "bar"
order = 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add more test cases?

  1. All items have order present.
  2. Order is negative.
  3. Only a few items have order present

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have 1 and 3 on the same test. We can just add orders to all the items and leave one empty and check if it is set to 0(the expected default value).

About 2, I don't see we handling that in any other part of the provider for app or agent metadata order, but putting some thoughts on that, I think it should not be a problem since you can still sort things by negative numbers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
item {
key = "secret"
Expand Down Expand Up @@ -66,6 +67,7 @@ func TestMetadata(t *testing.T) {
"item.0.key": "foo",
"item.0.value": "bar",
"item.0.sensitive": "false",
"item.0.order": "4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this is not enough for metadata items. See the comment on top of this function.

PS. VS code debugger is very handy when dealing with Terraform schema.

"item.1.key": "secret",
"item.1.value": "squirrel",
"item.1.sensitive": "true",
Expand Down
Loading