From f5a7f45ffbab5fd0039c665e078a040c13abff37 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Mon, 13 May 2019 16:52:25 -0700 Subject: [PATCH] internal/initwd: Fix module installation error The "err" variable in the MaybeRelativePathErr condition was masking the original err with nil in the "else" case of this branch, causing the error message to be incomplete. While here, also tweaked the wording to say "Could not download" rather than "Error attempting to download", both to say the same thing in fewer words and because the summary line above already starts with "Error:" when we print out this message, so it looks weird to have both lines start with the same word. --- internal/initwd/module_install.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/initwd/module_install.go b/internal/initwd/module_install.go index c07591bf7..822bc4f1e 100644 --- a/internal/initwd/module_install.go +++ b/internal/initwd/module_install.go @@ -428,7 +428,7 @@ func (i *ModuleInstaller) installRegistryModule(req *earlyconfig.ModuleRequest, diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to download module", - fmt.Sprintf("Error attempting to download module %q (%s:%d) source code from %q: %s.", req.Name, req.CallPos.Filename, req.CallPos.Line, dlAddr, err), + fmt.Sprintf("Could not download module %q (%s:%d) source code from %q: %s.", req.Name, req.CallPos.Filename, req.CallPos.Line, dlAddr, err), )) return nil, nil, diags } @@ -482,7 +482,7 @@ func (i *ModuleInstaller) installGoGetterModule(req *earlyconfig.ModuleRequest, modDir, err := getter.getWithGoGetter(instPath, req.SourceAddr) if err != nil { - if err, ok := err.(*MaybeRelativePathErr); ok { + if _, ok := err.(*MaybeRelativePathErr); ok { log.Printf( "[TRACE] ModuleInstaller: %s looks like a local path but is missing ./ or ../", req.SourceAddr, @@ -507,7 +507,7 @@ func (i *ModuleInstaller) installGoGetterModule(req *earlyconfig.ModuleRequest, diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to download module", - fmt.Sprintf("Error attempting to download module %q (%s:%d) source code from %q: %s", req.Name, req.CallPos.Filename, req.CallPos.Line, packageAddr, err), + fmt.Sprintf("Could not download module %q (%s:%d) source code from %q: %s", req.Name, req.CallPos.Filename, req.CallPos.Line, packageAddr, err), )) } return nil, diags