check for errors when loading a backend config
We can't dereference the config module if there were any errors loading it.
This commit is contained in:
parent
8c966a85ee
commit
a8df5586c0
|
@ -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