Skip to content

Commit 6da61bf

Browse files
committed
revert change to installModules diag handling
Error diags from c.installModules() no longer cause getModules() to exit early. Whether installModules completed successfully, errored, or was cancelled, we try to update the manifest as best we can, preferring incomplete information to none.
1 parent 7022876 commit 6da61bf

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎internal/command/init.go‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ func (c *InitCommand) getModules(path string, earlyRoot *tfconfig.Module, upgrad
345345

346346
installAbort, installDiags := c.installModules(path, upgrade, hooks)
347347
diags = diags.Append(installDiags)
348-
if installAbort || installDiags.HasErrors() {
349-
return true, true, diags
350-
}
348+
349+
// At this point, installModules may have generated error diags or been
350+
// aborted by SIGINT. In any case we continue and the manifest as best
351+
// we can.
351352

352353
// Since module installer has modified the module manifest on disk, we need
353354
// to refresh the cache of it in the loader.
@@ -362,7 +363,7 @@ func (c *InitCommand) getModules(path string, earlyRoot *tfconfig.Module, upgrad
362363
}
363364
}
364365

365-
return true, false, diags
366+
return true, installAbort, diags
366367
}
367368

368369
func (c *InitCommand) initCloud(root *configs.Module) (be backend.Backend, output bool, diags tfdiags.Diagnostics) {

‎internal/command/meta_config.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ func (m *Meta) installModules(rootDir string, upgrade bool, hooks initwd.ModuleI
178178
diags = diags.Append(fmt.Errorf("failed to create local modules directory: %s", err))
179179
return true, diags
180180
}
181-
// FIXME: KEM: does returning the abort here change behaviour in a particular error
182-
// case?
183181

184182
inst := m.moduleInstaller()
185183

0 commit comments

Comments
 (0)