From e73b2b4a4ed4c814131782572c007f85fbf442a3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 3 Sep 2018 13:17:40 +0300 Subject: Add repository-type value to task manifest and rename repository value to repository-url --- libbbot/manifest.cxx | 62 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 16 deletions(-) (limited to 'libbbot/manifest.cxx') diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx index c547198..cc8afb5 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -445,6 +445,13 @@ namespace bbot // Parse the task manifest. // + // The repository type value can go after the repository URL value. So we + // need to postpone creating the repository location until we went though + // all other values. + // + optional repo_url; + optional repo_type; + for (nv = p.next (); !nv.empty (); nv = p.next ()) { string& n (nv.name); @@ -484,25 +491,28 @@ namespace bbot if (version.release && version.release->empty ()) bad_value ("invalid task package version release"); } - else if (n == "repository") + else if (n == "repository-url") + { + if (repo_url) + bad_name ("task repository URL redefinition"); + + if (v.empty ()) + bad_value ("empty task repository URL"); + + repo_url = move (nv); + } + else if (n == "repository-type") { - if (!repository.empty ()) - bad_name ("task repository redefinition"); + if (repo_type) + bad_name ("task repository type redefinition"); try { - // Call remote/absolute repository location constructor (throws - // invalid_argument for relative location). - // - // @@ We probably need another name/value pair for the repository - // type, that should be filled by bbot controller. - // - repository = repository_location (repository_url (v), - repository_type::pkg); + repo_type = to_repository_type (v); } - catch (const invalid_argument& e) + catch (const invalid_argument&) { - bad_value (string ("invalid task repository: ") + e.what ()); + bad_value ("invalid task repository type '" + v + "'"); } } else if (n == "trust") @@ -568,14 +578,33 @@ namespace bbot if (version.empty ()) bad_value ("no task package version specified"); - if (repository.empty ()) - bad_value ("no task repository specified"); + if (!repo_url) + bad_value ("no task repository URL specified"); + + if (!repo_type) + bad_value ("no task repository type specified"); if (machine.empty ()) bad_value ("no task machine specified"); if (target.empty ()) bad_value ("no task target specified"); + + // Create the repository location. + // + try + { + // Call remote/absolute repository location constructor (throws + // invalid_argument for relative location). + // + repository = repository_location (repository_url (repo_url->value), + *repo_type); + } + catch (const invalid_argument& e) + { + nv = move (*repo_url); // Restore as bad_value() uses its line/column. + bad_value (string ("invalid task repository URL: ") + e.what ()); + } } void task_manifest:: @@ -595,7 +624,8 @@ namespace bbot s.next ("name", name.string ()); s.next ("version", version.string ()); - s.next ("repository", repository.string ()); + s.next ("repository-url", repository.string ()); + s.next ("repository-type", to_string (repository.type ())); for (const auto& v: trust) s.next ("trust", v); -- cgit v1.1