From 6da61bf07b527e9c6c5ac1e04d6adb068a15ead3 Mon Sep 17 00:00:00 2001 From: Katy Moe Date: Tue, 9 Nov 2021 13:15:13 +0000 Subject: [PATCH] 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. --- internal/command/init.go | 9 +++++---- internal/command/meta_config.go | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/command/init.go b/internal/command/init.go index b8ba6b9ff..a44fba3dc 100644 --- a/internal/command/init.go +++ b/internal/command/init.go @@ -345,9 +345,10 @@ func (c *InitCommand) getModules(path string, earlyRoot *tfconfig.Module, upgrad installAbort, installDiags := c.installModules(path, upgrade, hooks) diags = diags.Append(installDiags) - if installAbort || installDiags.HasErrors() { - return true, true, diags - } + + // At this point, installModules may have generated error diags or been + // aborted by SIGINT. In any case we continue and the manifest as best + // we can. // Since module installer has modified the module manifest on disk, we need // to refresh the cache of it in the loader. @@ -362,7 +363,7 @@ func (c *InitCommand) getModules(path string, earlyRoot *tfconfig.Module, upgrad } } - return true, false, diags + return true, installAbort, diags } func (c *InitCommand) initCloud(root *configs.Module) (be backend.Backend, output bool, diags tfdiags.Diagnostics) { diff --git a/internal/command/meta_config.go b/internal/command/meta_config.go index 0abaf52a7..d19389283 100644 --- a/internal/command/meta_config.go +++ b/internal/command/meta_config.go @@ -178,8 +178,6 @@ func (m *Meta) installModules(rootDir string, upgrade bool, hooks initwd.ModuleI diags = diags.Append(fmt.Errorf("failed to create local modules directory: %s", err)) return true, diags } - // FIXME: KEM: does returning the abort here change behaviour in a particular error - // case? inst := m.moduleInstaller()