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

Return template parameters in consistent order#2975

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

Merged
dwahler merged 3 commits intomainfromdwahler/2471-template-variable-order
Jul 13, 2022

Conversation

dwahler
Copy link
Contributor

This PR makes the order in which we display and prompt for template parameters deterministic and consistent. It involves two different functional changes:

  • The Terraform provisioner now sorts the returned list ofParameterSchema messages to match the order of theirvariable blocks in the template source (first lexicographically by filename, then by line number)
  • coderd persists the variable ordering using a newparameter_schemas.index database column, and sorts by that column when querying for parameters

For template versions that existed prior to this change, the database migration initializes the index column by putting the variable names for each version in lexicographic order, since we don't know the original source order.

Fixes#2471

@dwahlerdwahler marked this pull request as ready for reviewJuly 13, 2022 19:28
@dwahlerdwahler requested a review froma teamJuly 13, 2022 19:29
Copy link
Member

@kylecarbskylecarbs left a comment

Choose a reason for hiding this comment

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

Looks good to me. Fun change!

Comment on lines +26 to +33
// Sort variables by (filename, line) to make the ordering consistent
variables := make([]*tfconfig.Variable, 0, len(module.Variables))
for _, v := range module.Variables {
variables = append(variables, v)
}
sort.Slice(variables, func(i, j int) bool {
return compareSourcePos(variables[i].Pos, variables[j].Pos)
})
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty cool. It's awesome that customers will be able to control the order that variables display in the UI 👀

@dwahlerdwahler merged commitb5f5e90 intomainJul 13, 2022
@dwahlerdwahler deleted the dwahler/2471-template-variable-order branchJuly 13, 2022 20:29
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@kylecarbskylecarbskylecarbs approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Prompt for workspace/template variables in a consistent order
2 participants
@dwahler@kylecarbs

[8]ページ先頭

©2009-2025 Movatter.jp