command: show warnings from backend config validation

Previously we just silently ignored warnings from validating the backend
config, but now that we have a deprecated argument it's important to print
these out so users can respond to the deprecation warning.
This commit is contained in:
Martin Atkins 2017-05-30 15:41:12 -07:00
parent 5026e1d313
commit 5f9f13ab8f
1 changed files with 7 additions and 3 deletions

View File

@ -1341,14 +1341,18 @@ func (m *Meta) backendInitFromConfig(c *config.Backend) (backend.Backend, error)
// Validate
warns, errs := b.Validate(config)
for _, warning := range warns {
// We just write warnings directly to the UI. This isn't great
// since we're a bit deep here to be pushing stuff out into the
// UI, but sufficient to let us print out deprecation warnings
// and the like.
m.Ui.Warn(warning)
}
if len(errs) > 0 {
return nil, fmt.Errorf(
"Error configuring the backend %q: %s",
c.Type, multierror.Append(nil, errs...))
}
if len(warns) > 0 {
// TODO: warnings are currently ignored
}
// Configure
if err := b.Configure(config); err != nil {