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:
parent
1bb47ab9a5
commit
d7f23f0beb
|
@ -35,11 +35,11 @@ func (u *Upgrader) Upgrade(input ModuleSources, dir string) (ModuleSources, tfdi
|
||||||
var diags tfdiags.Diagnostics
|
var diags tfdiags.Diagnostics
|
||||||
|
|
||||||
an, err := u.analyze(input)
|
an, err := u.analyze(input)
|
||||||
an.ModuleDir = dir
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
diags = diags.Append(err)
|
diags = diags.Append(err)
|
||||||
return ret, diags
|
return ret, diags
|
||||||
}
|
}
|
||||||
|
an.ModuleDir = dir
|
||||||
|
|
||||||
for name, src := range input {
|
for name, src := range input {
|
||||||
ext := fileExt(name)
|
ext := fileExt(name)
|
||||||
|
|
Loading…
Reference in New Issue