configs/configupgrade: Don't panic if analyzer fails

Previously we were trying to access a field of the analysis object before
checking if analysis produced errors. The analysis function usually
returns a nil analysis on error, so this would result in a panic whenever
that happened.

Now we'll dereference the analysis object pointer only after checking for
errors, so we'll get a chance to report the analysis error to the user.
This commit is contained in:
Martin Atkins 2019-04-17 09:16:52 -07:00
parent 1bb47ab9a5
commit d7f23f0beb
1 changed files with 1 additions and 1 deletions

View File

@ -35,11 +35,11 @@ func (u *Upgrader) Upgrade(input ModuleSources, dir string) (ModuleSources, tfdi
var diags tfdiags.Diagnostics
an, err := u.analyze(input)
an.ModuleDir = dir
if err != nil {
diags = diags.Append(err)
return ret, diags
}
an.ModuleDir = dir
for name, src := range input {
ext := fileExt(name)