You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently no documented convention by HashiCorp on the file name conventions and where exactly a block should reside. There are some known conventions folks have adopted though, such as
variable blocks in variables.tf
output blocks in outputs.tf
Users can do refactoring today by copying and pasting these blocks around. How easy that is will be relative to people's opinions, amount of code being refactored and probably other factors.
The server could make refactoring which involves moving blocks between files easier, especially for users who have keybinding for code actions and use them frequently when refactoring.
For example the user may start withmain.tf
terraform {
// ...
}
variable"foo" {}
and end with two files,
main.tf
terraform {
// ...
}
variables.tf
variable"foo" {}
Proposal
Provide code action which can move a block into a new or existing file
check
data
import
locals
module
moved
output
provider
resource
terraform
variable
Needs research
It is not clear whether this code action would satisfy the definition of the standard kind refactor.extract. We may need to consider a different kind, or generic refactor.
Future thoughts
Eventually it may be useful to set and document conventions and provide more opinionated code actions, such as "move all variable blocks into variables.tf" and similar.
That is however not just implementation/technical work but a matter of getting buy in from involved teams internally on these opinions and documenting them first.
The text was updated successfully, but these errors were encountered:
Background
There is currently no documented convention by HashiCorp on the file name conventions and where exactly a block should reside. There are some known conventions folks have adopted though, such as
variable
blocks invariables.tf
output
blocks inoutputs.tf
Users can do refactoring today by copying and pasting these blocks around. How easy that is will be relative to people's opinions, amount of code being refactored and probably other factors.
The server could make refactoring which involves moving blocks between files easier, especially for users who have keybinding for code actions and use them frequently when refactoring.
For example the user may start with
main.tf
and end with two files,
main.tf
variables.tf
Proposal
check
data
import
locals
module
moved
output
provider
resource
terraform
variable
Needs research
It is not clear whether this code action would satisfy the definition of the standard kind
refactor.extract
. We may need to consider a different kind, or genericrefactor
.Future thoughts
Eventually it may be useful to set and document conventions and provide more opinionated code actions, such as "move all variable blocks into
variables.tf
" and similar.That is however not just implementation/technical work but a matter of getting buy in from involved teams internally on these opinions and documenting them first.
The text was updated successfully, but these errors were encountered: