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 @@ ...@@ -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 gk
.declareMethod("getBaseUrl", function (url) { .declareMethod("getBaseUrl", function (url) {
var base_url, url_uri = URI(url); var base_url, url_uri = URI(url);
...@@ -232,7 +242,7 @@ ...@@ -232,7 +242,7 @@
.declareMethod("loadSoftwareJSON", function (url) { .declareMethod("loadSoftwareJSON", function (url) {
return getJSON(url) return getJSON(url)
.push(function (json) { .push(function (json) {
return JSON.parse(json); return validateSoftwareJSONSchema(json);
}); });
}) })
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>999.27487.10946.52445</string> </value> <value> <string>999.31669.11148.21196</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1649686390.12</float> <float>1649728041.67</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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