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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user