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

Improve UX for different versions of the same module #895

Open
4 tasks
dbanck opened this issue Apr 26, 2022 · 0 comments
Open
4 tasks

Improve UX for different versions of the same module #895

dbanck opened this issue Apr 26, 2022 · 0 comments
Labels
enhancement New feature or request modules Functionality related to the module block and modules generally technical-debt

Comments

@dbanck
Copy link
Member

dbanck commented Apr 26, 2022

Background

In #874, we introduced links from the module source to the documentation for registry modules. We use the module source and the module version to build the URL.

When someone uses different versions of the same module, the only latest module call will be stored and used to build the link.

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.14.0"
}

module "vpc_legacy" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "2.78.0"
}

This problem occurs because of the way we generate dependency keys for dependent schemas. The current approach only uses the source as an identifier and ignores the version.

Taking the version into account will provide better autocompletion and link to the correct version of the module when accessing the documentation.

Challenges

  • A module version can contain version-constraints (e.g. >= 3.0.0, < 3.14.0) which first need to be resolved to a version before they can be matched
  • A module version can be omitted, so the latest version is assumed
  • If version becomes a dependency key in the schema it will lead to unintended effects, like another link inside the body

CleanShot 2022-04-26 at 15 14 36@2x

Proposal

hcl-lang

terraform-schema

  • Extend SchemaForModule to take the module version into account when building schemas for dependent module blocks
  • Mark the version attribute for module blocks as dependency key
  • Mark the source attribute for module blocks as linkable

TODO?

@dbanck dbanck added enhancement New feature or request modules Functionality related to the module block and modules generally labels Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request modules Functionality related to the module block and modules generally technical-debt
Projects
None yet
Development

No branches or pull requests

2 participants