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.
This commit is contained in:
Martin Atkins 2019-05-13 16:52:25 -07:00
parent 038621a8ed
commit f5a7f45ffb
1 changed files with 3 additions and 3 deletions

View File

@ -428,7 +428,7 @@ func (i *ModuleInstaller) installRegistryModule(req *earlyconfig.ModuleRequest,
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,
"Failed to download module", "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 return nil, nil, diags
} }
@ -482,7 +482,7 @@ func (i *ModuleInstaller) installGoGetterModule(req *earlyconfig.ModuleRequest,
modDir, err := getter.getWithGoGetter(instPath, req.SourceAddr) modDir, err := getter.getWithGoGetter(instPath, req.SourceAddr)
if err != nil { if err != nil {
if err, ok := err.(*MaybeRelativePathErr); ok { if _, ok := err.(*MaybeRelativePathErr); ok {
log.Printf( log.Printf(
"[TRACE] ModuleInstaller: %s looks like a local path but is missing ./ or ../", "[TRACE] ModuleInstaller: %s looks like a local path but is missing ./ or ../",
req.SourceAddr, req.SourceAddr,
@ -507,7 +507,7 @@ func (i *ModuleInstaller) installGoGetterModule(req *earlyconfig.ModuleRequest,
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,
"Failed to download module", "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 return nil, diags