1
0
mirror of https://github.com/rancher/os.git synced 2025-09-05 00:37:12 +00:00

Tell the user if the interpreted cloud confg is invalid and then exit

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit
2017-07-17 12:17:41 +10:00
parent 7fb9afe39c
commit cbcdb2628c
4 changed files with 19 additions and 3 deletions

View File

@@ -71,8 +71,19 @@ func LoadConfigWithPrefix(dirPrefix string) *CloudConfig {
cfg := &CloudConfig{}
if err := util.Convert(rawCfg, cfg); err != nil {
log.Errorf("Failed to parse configuration: %s", err)
log.Errorf("EXITING: Failed to parse configuration: %s", err)
log.Debugf("Bad cfg:\n%v\n", rawCfg)
// no point returning {}, it'll just sit there broken
// TODO: print some context around what failed..
validationErrors, err := ValidateRawCfg(rawCfg)
if err != nil {
log.Fatal(err)
}
for _, validationError := range validationErrors.Errors() {
log.Error(validationError)
}
// TODO: I'd love to panic & recover(), for issues on boot, but it doesn't work yet
os.Exit(-1)
return &CloudConfig{}
}
cfg = amendNils(cfg)