Commit fabe007a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Use json schema to validate the software.cfg.json

parent 0150fdee
......@@ -210,6 +210,16 @@
});
}
function validateSoftwareJSONSchema(json) {
return getJSON("slapos_load_software_schema.json")
.push(function (schema) {
if (!tv4.validate(json, schema)) {
throw new Error("Non valid JSON for software.cfg.json:" + json);
}
return JSON.parse(json);
});
}
gk
.declareMethod("getBaseUrl", function (url) {
var base_url, url_uri = URI(url);
......@@ -232,7 +242,7 @@
.declareMethod("loadSoftwareJSON", function (url) {
return getJSON(url)
.push(function (json) {
return JSON.parse(json);
return validateSoftwareJSONSchema(json);
});
})
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>999.27487.10946.52445</string> </value>
<value> <string>999.31669.11148.21196</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1649686390.12</float>
<float>1649728041.67</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment