Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add order to coder_metadata#450

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
BrunoQuaresma wants to merge6 commits intomain
base:main
Choose a base branch
Loading
frombq/feat-order-metadta

Conversation

@BrunoQuaresma
Copy link
Contributor

Closes#325

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,
Computed:true,
Copy link
Member

Choose a reason for hiding this comment

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

If you setComputed on an attribute, it cannot be changed. Ref:https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#computed

BrunoQuaresma reacted with thumbs up emoji
Copy link
Member

@johnstcnjohnstcn left a comment
edited
Loading

Choose a reason for hiding this comment

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

You will need to update the tests and runmake fmt /make gen in order for CI to pass.
My suggestion would also be to add/update tests in./integration for this change.

@BrunoQuaresma
Copy link
ContributorAuthor

BrunoQuaresma commentedOct 22, 2025
edited
Loading

@johnstcn I have updated theTestMetadata to include one item with theorder attribute and added a check(you can check the "Files changed" tab), but it is not working 😞

Error:      Not equal: expected: "4"actual  : "0"

Do you have any idea why?

@BrunoQuaresma
Copy link
ContributorAuthor

@johnstcn about adding an integration test for this, I think this change is simple enough to be tested only in theTestMetadata, but I would like to understand why you think an integration test for this would be necessary.

@johnstcn
Copy link
Member

I would like to understand why you think an integration test for this would be necessary.

Purely out of paranoia, but it's only a suggestion.

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 haveorder present.
  2. Order is negative.
  3. Only a few items haveorder present

Copy link
ContributorAuthor

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.

👍

"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... isForceNew 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 inagent.metadata.order so it may be no harm to be safe and stick to the status quo.

mtojek reacted with thumbs up emoji
"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 thisfunction.

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

BrunoQuaresma reacted with thumbs up emoji
@BrunoQuaresma
Copy link
ContributorAuthor

@johnstcn related to the integration tests, whatminVersion should I set when testing new features?

@johnstcn
Copy link
Member

johnstcn commentedOct 23, 2025
edited
Loading

@johnstcn related to the integration tests, whatminVersion should I set when testing new features?

If you setminVersion: "v0.0.0" then the integration test will always run.
Otherwise, the test will only run based on the version of Coder against which the integration test is actually running.

In CI, the integration tests run against three different versions (fromgo run ./scripts/coderversion.go):

  • CODER_MAINLINE_VERSION: latest mainline version
  • CODER_STABLE_VERSION: latest stable version
  • CODER_OLDSTABLE_VERSION: previous stable version

So basically if a particular integration test only makes sense to run from a particular Coder version onwards, you setminVersion to that version.

BrunoQuaresma reacted with thumbs up emoji

returnnil
}
varvalueAsIntint64
gocty.FromCtyValue(value,&valueAsInt)
Copy link
Member

Choose a reason for hiding this comment

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

This can return an error, so we may to modify the return signature to(interface{}, error) and handle it in the calling function.

BrunoQuaresma reacted with thumbs up emoji
Comment on lines +142 to +149
funcvalueAsInt(value cty.Value) (interface{},error) {
ifvalue.IsNull() {
returnnil,nil
}
varvalueAsIntint64
err:=gocty.FromCtyValue(value,&valueAsInt)
returnvalueAsInt,err
}
Copy link
Member

Choose a reason for hiding this comment

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

With this change, it would be good to have a test for a non-numeric value fororder.

Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

Once tests pointed our by Cian are 👍 , feel free to proceed.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@johnstcnjohnstcnjohnstcn requested changes

@mtojekmtojekmtojek left review comments

Requested changes must be addressed to merge this pull request.

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Addorder tocoder_metadata

3 participants

@BrunoQuaresma@johnstcn@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp