Merge branch 'master' of ssh://gitlab.com/iroddis/daggy
This commit is contained in:
@@ -121,28 +121,42 @@ namespace daggy {
|
||||
|
||||
// Grab the standard fields with defaults;
|
||||
if (spec.HasMember("isGenerator")) {
|
||||
if (! spec["isGenerator"].IsBool())
|
||||
throw std::runtime_error("isGenerator must be a boolean value");
|
||||
task.isGenerator = spec["isGenerator"].GetBool();
|
||||
}
|
||||
|
||||
if (spec.HasMember("maxRetries")) {
|
||||
if (! spec["maxRetries"].IsInt())
|
||||
throw std::runtime_error("maxRetries must be an integer");
|
||||
task.maxRetries = spec["maxRetries"].GetInt();
|
||||
}
|
||||
|
||||
if (spec.HasMember("retryIntervalSeconds")) {
|
||||
if (! spec["retryIntervalSeconds"].IsInt())
|
||||
throw std::runtime_error("retryIntervalSeconds must be an integer");
|
||||
task.retryIntervalSeconds = spec["retryIntervalSeconds"].GetInt();
|
||||
}
|
||||
|
||||
// Children / parents
|
||||
if (spec.HasMember("children")) {
|
||||
if (! spec["children"].IsArray())
|
||||
throw std::runtime_error("task.children must be specified as an array of strings");
|
||||
const auto &specChildren = spec["children"].GetArray();
|
||||
for (size_t c = 0; c < specChildren.Size(); ++c) {
|
||||
if (! specChildren[c].IsString())
|
||||
throw std::runtime_error("task.children must be specified as an array of strings");
|
||||
task.children.insert(specChildren[c].GetString());
|
||||
}
|
||||
}
|
||||
|
||||
if (spec.HasMember("parents")) {
|
||||
if (! spec["parents"].IsArray())
|
||||
throw std::runtime_error("task.parents must be specified as an array of strings");
|
||||
const auto &specParents = spec["parents"].GetArray();
|
||||
for (size_t c = 0; c < specParents.Size(); ++c) {
|
||||
if (! specParents[c].IsString())
|
||||
throw std::runtime_error("task.parents must be specified as an array of strings");
|
||||
task.parents.insert(specParents[c].GetString());
|
||||
}
|
||||
}
|
||||
@@ -154,13 +168,16 @@ namespace daggy {
|
||||
for (auto it = params.MemberBegin(); it != params.MemberEnd(); ++it) {
|
||||
if (!it->name.IsString())
|
||||
throw std::runtime_error("job key must be a string.");
|
||||
auto name = it->name.GetString();
|
||||
|
||||
if (it->value.IsArray()) {
|
||||
std::vector<std::string> values;
|
||||
for (size_t i = 0; i < it->value.Size(); ++i) {
|
||||
if (! it->value[i].IsString())
|
||||
throw std::runtime_error(std::string{"All entries in job."} + name + " must be strings");
|
||||
values.emplace_back(it->value[i].GetString());
|
||||
}
|
||||
task.job.insert_or_assign(it->name.GetString(), values);
|
||||
task.job.insert_or_assign(name, values);
|
||||
}
|
||||
else if (it->value.IsString()) {
|
||||
task.job.insert_or_assign(it->name.GetString(),
|
||||
|
||||
Reference in New Issue
Block a user