command: validate backend config
The validation itself was added a couple weeks ago but I forgot to actually call it. :sad:
This commit is contained in:
parent
a2d78b62aa
commit
03493f7d46
|
@ -237,6 +237,12 @@ func (m *Meta) backendConfig(opts *BackendOpts) (*config.Backend, error) {
|
||||||
backend.RawConfig = backend.RawConfig.Merge(rc)
|
backend.RawConfig = backend.RawConfig.Merge(rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate the backend early. We have to do this before the normal
|
||||||
|
// config validation pass since backend loading happens earlier.
|
||||||
|
if errs := backend.Validate(); len(errs) > 0 {
|
||||||
|
return nil, multierror.Append(nil, errs...)
|
||||||
|
}
|
||||||
|
|
||||||
// Return the configuration which may or may not be set
|
// Return the configuration which may or may not be set
|
||||||
return backend, nil
|
return backend, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,24 @@ func TestMetaBackend_emptyLegacyRemote(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify that interpolations result in an error
|
||||||
|
func TestMetaBackend_configureInterpolation(t *testing.T) {
|
||||||
|
// Create a temporary working directory that is empty
|
||||||
|
td := tempDir(t)
|
||||||
|
copy.CopyDir(testFixturePath("backend-new-interp"), td)
|
||||||
|
defer os.RemoveAll(td)
|
||||||
|
defer testChdir(t, td)()
|
||||||
|
|
||||||
|
// Setup the meta
|
||||||
|
m := testMetaBackend(t, nil)
|
||||||
|
|
||||||
|
// Get the backend
|
||||||
|
_, err := m.Backend(&BackendOpts{Init: true})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("should error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Newly configured backend
|
// Newly configured backend
|
||||||
func TestMetaBackend_configureNew(t *testing.T) {
|
func TestMetaBackend_configureNew(t *testing.T) {
|
||||||
// Create a temporary working directory that is empty
|
// Create a temporary working directory that is empty
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
variable "foo" { default = "bar" }
|
||||||
|
|
||||||
|
terraform {
|
||||||
|
backend "local" {
|
||||||
|
path = "${var.foo}"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue