1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 23:04:41 +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

@@ -31,11 +31,15 @@ func ConvertKeysToStrings(item interface{}) interface{} {
}
}
func Validate(bytes []byte) (*gojsonschema.Result, error) {
func ValidateBytes(bytes []byte) (*gojsonschema.Result, error) {
var rawCfg map[string]interface{}
if err := yaml.Unmarshal([]byte(bytes), &rawCfg); err != nil {
return nil, err
}
return ValidateRawCfg(rawCfg)
}
func ValidateRawCfg(rawCfg interface{}) (*gojsonschema.Result, error) {
rawCfg = ConvertKeysToStrings(rawCfg).(map[string]interface{})
loader := gojsonschema.NewGoLoader(rawCfg)
schemaLoader := gojsonschema.NewStringLoader(schema)