Skip to content
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

Module View Provider #746

Merged
merged 1 commit into from
Sep 23, 2021
Merged

Module View Provider #746

merged 1 commit into from
Sep 23, 2021

Conversation

jpogran
Copy link
Contributor

@jpogran jpogran commented Aug 27, 2021

  • List modules used in current workspace
  • Detect module type and use Terraform icon
  • Detect module type and use Github icon
  • Detect module type and use local folder icon
  • Provide context menu item to open link to documentation website
  • List dependent modules used by module in expanded state

Module view inside Explorer view container, with nested modules displayed

image

Documentation Link

image

Closes #698

Needs hashicorp/terraform-ls#632

@jpogran jpogran changed the title f module view Module View Provider Aug 27, 2021
@jpogran jpogran linked an issue Aug 27, 2021 that may be closed by this pull request
@jpogran jpogran self-assigned this Aug 27, 2021
@jpogran jpogran force-pushed the f-module-view branch 6 times, most recently from b8ea335 to 8ef2037 Compare September 2, 2021 20:34
@jpogran jpogran force-pushed the f-module-view branch 3 times, most recently from 938d2a9 to 58b857f Compare September 13, 2021 23:17
jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 13, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746
@jpogran jpogran added the enhancement New feature or request label Sep 13, 2021
@jpogran jpogran marked this pull request as ready for review September 13, 2021 23:20
@radeksimko radeksimko self-requested a review September 15, 2021 10:46
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

I left you some comments in-line, mostly naming related, I reckon we should probably first resolve #771 and leverage the code here as well to avoid reintroducing the same bug.

src/providers/moduleProvider.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/providers/moduleProvider.ts Outdated Show resolved Hide resolved
src/providers/moduleProvider.ts Show resolved Hide resolved
src/providers/moduleProvider.ts Show resolved Hide resolved
src/providers/moduleProvider.ts Outdated Show resolved Hide resolved
src/providers/moduleProvider.ts Outdated Show resolved Hide resolved
@jpogran jpogran force-pushed the f-module-view branch 6 times, most recently from c4a63b0 to a18a79e Compare September 22, 2021 16:03
@jpogran jpogran requested a review from radeksimko September 22, 2021 16:03
jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 22, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746
src/providers/moduleProvider.ts Outdated Show resolved Hide resolved
src/providers/moduleProvider.ts Outdated Show resolved Hide resolved
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

This looks pretty good to me, aside from that minor gitlab comment and from reflecting any remaining API changes in hashicorp/terraform-ls#63 here

jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 23, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746
This adds a new view to the Explorer view container in the activity bar that shows a list of modules referenced in the module opened. Each module is styled based on its type, and will show dependent modules that can be expanded.

It also introduces two new commands, `refresh` and `open documentation`, that are tied to the view and can be used in the view title bar as well as in context menus for each module.

This view will be only active when the extension activates, and will only display information when a module is open that references modules. If no modules are found, a note is left in the window.

This also introduces a new approach to organizing the code in feature files instead of entirely inside the extension.ts file.
@jpogran jpogran requested a review from radeksimko September 23, 2021 14:51
jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 23, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746

TODO: It is technically incorrect to use the package hashicorp/terraform-registry-address here as it is written to parse Terraform provider addresses and may not work correctly on Terraform module addresses. The proper approach is to create a new parsing library that is dedicated to parsing these kinds of addresses correctly, by re-using the logic defined in the authorative source: hashicorp/terraform/internal/addrs/module_source.go. However this works enough for now to identify module types for display in vscode-terraform.
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

LGTM

jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 23, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746

TODO: It is technically incorrect to use the package hashicorp/terraform-registry-address here as it is written to parse Terraform provider addresses and may not work correctly on Terraform module addresses. The proper approach is to create a new parsing library that is dedicated to parsing these kinds of addresses correctly, by re-using the logic defined in the authorative source: hashicorp/terraform/internal/addrs/module_source.go. However this works enough for now to identify module types for display in vscode-terraform.

This also increases the CI timeout for the build process. We think the introduction of go-getter inflated the dependency tree and adds more time. At the moment it is more economical to eat the build time than take the engineering time to copy the methods needed to detect the correct module sources.
jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 23, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746

TODO: It is technically incorrect to use the package hashicorp/terraform-registry-address here as it is written to parse Terraform provider addresses and may not work correctly on Terraform module addresses. The proper approach is to create a new parsing library that is dedicated to parsing these kinds of addresses correctly, by re-using the logic defined in the authorative source: hashicorp/terraform/internal/addrs/module_source.go. However this works enough for now to identify module types for display in vscode-terraform.

This also increases the CI timeout for the build process. We think the introduction of go-getter inflated the dependency tree and adds more time. At the moment it is more economical to eat the build time than take the engineering time to copy the methods needed to detect the correct module sources.
jpogran added a commit to hashicorp/terraform-ls that referenced this pull request Sep 23, 2021
Adds a handler to return a list of modules used by a given module path. Each module returned shows the module name, version, documentation link and what type of module it is (local, github, or terraform registry). It also detects if a module has nested modules, and adds them in the `DependentModules` property.

This is meant to be used in tandem with hashicorp/vscode-terraform#746

TODO: It is technically incorrect to use the package hashicorp/terraform-registry-address here as it is written to parse Terraform provider addresses and may not work correctly on Terraform module addresses. The proper approach is to create a new parsing library that is dedicated to parsing these kinds of addresses correctly, by re-using the logic defined in the authorative source: hashicorp/terraform/internal/addrs/module_source.go. However this works enough for now to identify module types for display in vscode-terraform.

This also increases the CI timeout for the build process. We think the introduction of go-getter inflated the dependency tree and adds more time. At the moment it is more economical to eat the build time than take the engineering time to copy the methods needed to detect the correct module sources.
@jpogran jpogran merged commit 98ed855 into main Sep 23, 2021
@jpogran jpogran deleted the f-module-view branch September 23, 2021 16:41
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display module hierarchy in the UI
2 participants