mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Merge pull request #33634 from hashicorp/jbardin/init-from-module-warnings
Allow `get` and `init -from-module` to complete when there are configuration validation errors
This commit is contained in:
@@ -159,7 +159,7 @@ func testModuleWithSnapshot(t *testing.T, name string) (*configs.Config, *config
|
||||
// sources only this ultimately just records all of the module paths
|
||||
// in a JSON file so that we can load them below.
|
||||
inst := initwd.NewModuleInstaller(loader.ModulesDir(), loader, registry.NewClient(nil, nil))
|
||||
_, instDiags := inst.InstallModules(context.Background(), dir, "tests", true, initwd.ModuleInstallHooksImpl{})
|
||||
_, instDiags := inst.InstallModules(context.Background(), dir, "tests", true, false, initwd.ModuleInstallHooksImpl{})
|
||||
if instDiags.HasErrors() {
|
||||
t.Fatal(instDiags.Err())
|
||||
}
|
||||
|
||||
@@ -90,5 +90,5 @@ func getModules(ctx context.Context, m *Meta, path string, testsDir string, upgr
|
||||
Ui: m.Ui,
|
||||
ShowLocalPaths: true,
|
||||
}
|
||||
return m.installModules(ctx, path, testsDir, upgrade, hooks)
|
||||
return m.installModules(ctx, path, testsDir, upgrade, true, hooks)
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ func (c *InitCommand) getModules(ctx context.Context, path, testsDir string, ear
|
||||
ShowLocalPaths: true,
|
||||
}
|
||||
|
||||
installAbort, installDiags := c.installModules(ctx, path, testsDir, upgrade, hooks)
|
||||
installAbort, installDiags := c.installModules(ctx, path, testsDir, upgrade, false, hooks)
|
||||
diags = diags.Append(installDiags)
|
||||
|
||||
// At this point, installModules may have generated error diags or been
|
||||
|
||||
@@ -183,7 +183,7 @@ func (m *Meta) loadHCLFile(filename string) (hcl.Body, tfdiags.Diagnostics) {
|
||||
// can then be relayed to the end-user. The uiModuleInstallHooks type in
|
||||
// this package has a reasonable implementation for displaying notifications
|
||||
// via a provided cli.Ui.
|
||||
func (m *Meta) installModules(ctx context.Context, rootDir, testsDir string, upgrade bool, hooks initwd.ModuleInstallHooks) (abort bool, diags tfdiags.Diagnostics) {
|
||||
func (m *Meta) installModules(ctx context.Context, rootDir, testsDir string, upgrade, installErrsOnly bool, hooks initwd.ModuleInstallHooks) (abort bool, diags tfdiags.Diagnostics) {
|
||||
ctx, span := tracer.Start(ctx, "install modules")
|
||||
defer span.End()
|
||||
|
||||
@@ -203,7 +203,7 @@ func (m *Meta) installModules(ctx context.Context, rootDir, testsDir string, upg
|
||||
|
||||
inst := initwd.NewModuleInstaller(m.modulesDir(), loader, m.registryClient())
|
||||
|
||||
_, moreDiags := inst.InstallModules(ctx, rootDir, testsDir, upgrade, hooks)
|
||||
_, moreDiags := inst.InstallModules(ctx, rootDir, testsDir, upgrade, installErrsOnly, hooks)
|
||||
diags = diags.Append(moreDiags)
|
||||
|
||||
if ctx.Err() == context.Canceled {
|
||||
|
||||
Reference in New Issue
Block a user