diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/mod-build-task.cxx | 45 | ||||
-rw-r--r-- | mod/module.cli | 8 | ||||
-rw-r--r-- | mod/types-parsers.cxx | 24 | ||||
-rw-r--r-- | mod/types-parsers.hxx | 8 |
4 files changed, 74 insertions, 11 deletions
diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index 4b0165f..19907ea 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -214,6 +214,40 @@ handle (request& rq, response& rs) task_response_manifest tsm; + auto serialize_task_response_manifest = [&tsm, &rs] () + { + // @@ Probably it would be a good idea to also send some cache control + // headers to avoid caching by HTTP proxies. That would require + // extension of the web::response interface. + // + + manifest_serializer s (rs.content (200, "text/manifest;charset=utf-8"), + "task_response_manifest"); + tsm.serialize (s); + }; + + interactive_mode imode (tqm.effective_interactive_mode ()); + + // Restict the interactive mode (specified by the task request manifest) if + // the interactive parameter is specified and is other than "both". If + // values specified by the parameter and manifest are incompatible (false vs + // true), then just bail out responding with the manifest with an empty + // session. + // + if (params.interactive () != interactive_mode::both) + { + if (imode != interactive_mode::both) + { + if (params.interactive () != imode) + { + serialize_task_response_manifest (); + return true; + } + } + else + imode = params.interactive (); // Can only change both to true or false. + } + // Map build target configurations to machines that are capable of building // them. The first matching machine is selected for each configuration. // @@ -604,7 +638,6 @@ handle (request& rq, response& rs) using pkg_query = query<buildable_package>; using prep_pkg_query = prepared_query<buildable_package>; - interactive_mode imode (tqm.effective_interactive_mode ()); pkg_query pq (package_query<buildable_package> (params, imode)); // Transform (in-place) the interactive login information into the actual @@ -1495,14 +1528,6 @@ handle (request& rq, response& rs) } } - // @@ Probably it would be a good idea to also send some cache control - // headers to avoid caching by HTTP proxies. That would require extension - // of the web::response interface. - // - - manifest_serializer s (rs.content (200, "text/manifest;charset=utf-8"), - "task_response_manifest"); - tsm.serialize (s); - + serialize_task_response_manifest (); return true; } diff --git a/mod/module.cli b/mod/module.cli index 4c10826..ab72a9a 100644 --- a/mod/module.cli +++ b/mod/module.cli @@ -5,6 +5,7 @@ include <map>; include <regex>; include <libbpkg/manifest.hxx>; // repository_location +include <libbbot/manifest.hxx>; // interactive_mode include <web/xhtml/fragment.hxx>; @@ -842,9 +843,14 @@ namespace brep class build_task { - // Package repository canonical name (note: including pkg: type). + // Only consider packages from repositories with these canonical names + // (note: including pkg: type). // vector<string> repository | r; + + // Only consider tenants with this interactive build mode. + // + bbot::interactive_mode interactive = bbot::interactive_mode::both; }; class build_result diff --git a/mod/types-parsers.cxx b/mod/types-parsers.cxx index fd087bc..34a8bac 100644 --- a/mod/types-parsers.cxx +++ b/mod/types-parsers.cxx @@ -13,6 +13,7 @@ using namespace std; using namespace butl; using namespace bpkg; +using namespace bbot; using namespace web::xhtml; namespace brep @@ -114,6 +115,29 @@ namespace brep } } + // Parse interactive_mode. + // + void parser<interactive_mode>:: + parse (interactive_mode& x, bool& xs, scanner& s) + { + xs = true; + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const string v (s.next ()); + + try + { + x = to_interactive_mode (v); + } + catch (const invalid_argument&) + { + throw invalid_value (o, v); + } + } + // Parse page_form. // void parser<page_form>:: diff --git a/mod/types-parsers.hxx b/mod/types-parsers.hxx index c6da9f6..f10100c 100644 --- a/mod/types-parsers.hxx +++ b/mod/types-parsers.hxx @@ -10,6 +10,7 @@ #include <regex> #include <libbpkg/manifest.hxx> // repository_location +#include <libbbot/manifest.hxx> // interactive_mode #include <web/xhtml/fragment.hxx> @@ -58,6 +59,13 @@ namespace brep }; template <> + struct parser<bbot::interactive_mode> + { + static void + parse (bbot::interactive_mode&, bool&, scanner&); + }; + + template <> struct parser<page_form> { static void |