mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
Merge pull request #20662 from hashicorp/jbardin/unlock
check for errors when loading a backend config
This commit is contained in:
commit
17425c60f3
@ -173,6 +173,9 @@ func (m *Meta) dirIsConfigPath(dir string) bool {
|
|||||||
// directory even if loadBackendConfig succeeded.)
|
// directory even if loadBackendConfig succeeded.)
|
||||||
func (m *Meta) loadBackendConfig(rootDir string) (*configs.Backend, tfdiags.Diagnostics) {
|
func (m *Meta) loadBackendConfig(rootDir string) (*configs.Backend, tfdiags.Diagnostics) {
|
||||||
mod, diags := m.loadSingleModule(rootDir)
|
mod, diags := m.loadSingleModule(rootDir)
|
||||||
|
if diags.HasErrors() {
|
||||||
|
return nil, diags
|
||||||
|
}
|
||||||
return mod.Backend, diags
|
return mod.Backend, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,16 @@ func TestUnlock(t *testing.T) {
|
|||||||
if code := c.Run(args); code != 1 {
|
if code := c.Run(args); code != 1 {
|
||||||
t.Fatalf("bad: %d\n%s\n%s", code, ui.OutputWriter.String(), ui.ErrorWriter.String())
|
t.Fatalf("bad: %d\n%s\n%s", code, ui.OutputWriter.String(), ui.ErrorWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure we don't crash with arguments in the wrong order
|
||||||
|
args = []string{
|
||||||
|
"LOCK_ID",
|
||||||
|
"-force",
|
||||||
|
}
|
||||||
|
|
||||||
|
if code := c.Run(args); code != 1 {
|
||||||
|
t.Fatalf("bad: %d\n%s\n%s", code, ui.OutputWriter.String(), ui.ErrorWriter.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Newly configured backend
|
// Newly configured backend
|
||||||
|
Loading…
Reference in New Issue
Block a user