summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 20:10:52 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 20:10:52 -0500
commit72badbe8db656358dcb7f7d05e00578acdffab96 (patch)
treecf4d73b5a3deaa6607b5329e1a8f281eab4a5cc7 /hscript
parent321a65bdc34d2dbf9adfab198d58a9910975879f (diff)
downloadhorizon-72badbe8db656358dcb7f7d05e00578acdffab96.tar.gz
horizon-72badbe8db656358dcb7f7d05e00578acdffab96.tar.bz2
horizon-72badbe8db656358dcb7f7d05e00578acdffab96.tar.xz
horizon-72badbe8db656358dcb7f7d05e00578acdffab96.zip
hscript: Ensure required keys are present
Diffstat (limited to 'hscript')
-rw-r--r--hscript/script.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/hscript/script.cc b/hscript/script.cc
index 1bb2176..93d8cb4 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -121,9 +121,13 @@ struct Script::ScriptPrivate {
} else if(key_name == "rootpw") {
/*! TODO: implement */
return false;
+ } else if(key_name == "mount") {
+ /*! TODO: implement */
+ return false;
} else {
return false;
}
+#undef DUPLICATE_ERROR
}
};
@@ -232,6 +236,30 @@ const Script *Script::load(std::istream &sstream, const ScriptOptions opts) {
errors++;
}
+ /* Ensure no required keys are missing. */
+#define MISSING_ERROR(key) \
+ output_error("installfile:" + std::to_string(lineno),\
+ "expected value for key '" + key + "'",\
+ "this key is required", (opts.test(Pretty)));\
+ errors++;
+
+ if(!the_script->internal->network) {
+ MISSING_ERROR(std::string("network"))
+ }
+ if(!the_script->internal->hostname) {
+ MISSING_ERROR(std::string("hostname"))
+ }
+ if(the_script->internal->packages.size() == 0) {
+ MISSING_ERROR(std::string("pkginstall"))
+ }
+ if(!the_script->internal->rootpw) {
+ MISSING_ERROR(std::string("rootpw"))
+ }
+ if(the_script->internal->mounts.size() == 0) {
+ MISSING_ERROR(std::string("mount"))
+ }
+#undef MISSING_ERROR
+
output_message("parser", "0", "installfile",
std::to_string(errors) + " error(s), " +
std::to_string(warnings) + " warning(s).",