command/providers: Avoid crash when no configs found

This commit is contained in:
Radek Simko 2017-06-10 11:04:44 +01:00
parent 5f24491ea6
commit 86fbcfac83
No known key found for this signature in database
GPG Key ID: 6823F3DCCE01BB19
1 changed files with 7 additions and 0 deletions

View File

@ -43,6 +43,13 @@ func (c *ProvidersCommand) Run(args []string) int {
c.Ui.Error(fmt.Sprintf("Failed to load root config module: %s", err))
return 1
}
if root == nil {
c.Ui.Error(fmt.Sprintf(
"No configuration files found in the directory: %s\n\n"+
"This command requires configuration to run.",
configPath))
return 1
}
// Validate the config (to ensure the version constraints are valid)
err = root.Validate()