Merge pull request #20662 from hashicorp/jbardin/unlock

check for errors when loading a backend config
This commit is contained in:
James Bardin 2019-03-12 18:14:45 -04:00 committed by GitHub
commit 17425c60f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -173,6 +173,9 @@ func (m *Meta) dirIsConfigPath(dir string) bool {
// directory even if loadBackendConfig succeeded.)
func (m *Meta) loadBackendConfig(rootDir string) (*configs.Backend, tfdiags.Diagnostics) {
mod, diags := m.loadSingleModule(rootDir)
if diags.HasErrors() {
return nil, diags
}
return mod.Backend, diags
}

View File

@ -49,6 +49,16 @@ func TestUnlock(t *testing.T) {
if code := c.Run(args); code != 1 {
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