Skip to content

Commit

Permalink
always link to the latest module version
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed Jul 7, 2022
1 parent f9ec258 commit 3a730f0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/langserver/handlers/command/module_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (h *CmdHandler) parseModuleRecords(ctx context.Context, moduleCalls tfmod.M
docsLink := ""
if sourceType == TFREGISTRY {
var err error
docsLink, err = getModuleDocumentationLink(ctx, manifest.SourceAddr.String(), manifest.Version.String())
docsLink, err = getModuleDocumentationLink(ctx, manifest.SourceAddr.String())
if err != nil {
h.Logger.Printf("failed to get module docs link: %s", err)
}
Expand Down Expand Up @@ -116,10 +116,10 @@ func (h *CmdHandler) parseModuleRecords(ctx context.Context, moduleCalls tfmod.M
return list
}

func getModuleDocumentationLink(ctx context.Context, sourceAddr string, version string) (string, error) {
func getModuleDocumentationLink(ctx context.Context, sourceAddr string) (string, error) {
shortName := strings.TrimPrefix(sourceAddr, "registry.terraform.io/")

rawURL := fmt.Sprintf(`https://registry.terraform.io/modules/%s/%s`, shortName, version)
rawURL := fmt.Sprintf(`https://registry.terraform.io/modules/%s/latest`, shortName)

u, err := docsURL(ctx, rawURL, "workspace/executeCommand/module.calls")
if err != nil {
Expand Down

0 comments on commit 3a730f0

Please sign in to comment.