From 9f5b820aec37ac0a929e074ae2c859229da33b0f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 28 Apr 2023 22:14:14 +0300 Subject: Add support for upload handlers and implement brep-upload-bindist handler --- mod/mod-build-task.cxx | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'mod/mod-build-task.cxx') diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index 33a7f58..4b0165f 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -286,15 +286,14 @@ handle (request& rq, response& rs) b->toolchain_version.string () + '/' + to_string (ts)); - string result_url (options_->host () + - tenant_dir (options_->root (), b->tenant).string () + - "?build-result"); + string tenant (tenant_dir (options_->root (), b->tenant).string ()); + string result_url (options_->host () + tenant + "?build-result"); assert (transaction::has_current ()); assert (p->internal ()); // The package is expected to be buildable. - lazy_shared_ptr r (p->internal_repository.load ()); + shared_ptr r (p->internal_repository.load ()); strings fps; if (r->certificate_fingerprint) @@ -369,9 +368,43 @@ handle (request& rq, response& rs) move (t->interactive), move (b->worker_checksum)); + // Collect the build artifacts upload URLs, skipping those which are + // excluded with the upload-*-exclude configuration options. + // + vector upload_urls; + + for (const auto& ud: options_->upload_data ()) + { + const string& t (ud.first); + + auto exclude = [&t] (const multimap& mm, + const string& v) + { + auto range (mm.equal_range (t)); + + for (auto i (range.first); i != range.second; ++i) + { + if (i->second == v) + return true; + } + + return false; + }; + + if (!exclude (options_->upload_toolchain_exclude (), + b->toolchain_name) && + !exclude (options_->upload_repository_exclude (), + r->canonical_name)) + { + upload_urls.emplace_back (options_->host () + tenant + "?upload=" + t, + t); + } + } + return task_response_manifest (move (session), move (b->agent_challenge), move (result_url), + move (upload_urls), move (b->agent_checksum), move (task)); }; -- cgit v1.1