From d4900d85f7a5d791f89821713d02d3dd19361044 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 22 Feb 2024 11:17:25 +0300 Subject: Add support for tenant-associated service notifications --- mod/ci-common.hxx | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 mod/ci-common.hxx (limited to 'mod/ci-common.hxx') diff --git a/mod/ci-common.hxx b/mod/ci-common.hxx new file mode 100644 index 0000000..6f62c4b --- /dev/null +++ b/mod/ci-common.hxx @@ -0,0 +1,96 @@ +// file : mod/ci-common.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_CI_COMMON_HXX +#define MOD_CI_COMMON_HXX + +#include // database + +#include +#include + +#include + +#include +#include + +namespace brep +{ + class ci_start + { + public: + void + init (shared_ptr); + + // If the request handling has been performed normally, then return the + // information that corresponds to the CI result manifest (see CI Result + // Manifest in the manual). Otherwise (some internal has error occured), + // log the error and return nullopt. + // + // The arguments correspond to the CI request and overrides manifest + // values (see CI Request and Overrides Manifests in the manual). Note: + // request id and timestamp are generated by the implementation. + // + struct package + { + package_name name; + optional version; + }; + // Note that the inability to generate the reference is an internal + // error. Thus, it is not optional. + // + struct start_result + { + uint16_t status; + string message; + string reference; + vector> custom_result; + }; + + // In the optional service information, if id is empty, then the generated + // reference is used instead. + // + optional + start (const basic_mark& error, + const basic_mark& warn, + const basic_mark* trace, + optional&&, + const repository_location& repository, + const vector& packages, + const optional& client_ip, + const optional& user_agent, + const optional& interactive = nullopt, + const optional& simulate = nullopt, + const vector>& custom_request = {}, + const vector>& overrides = {}); + + // Helpers. + // + + // Serialize the start result as a CI result manifest. + // + static void + serialize_manifest (const start_result&, ostream&, bool long_lines = false); + + private: + shared_ptr options_; + }; + + class ci_cancel + { + public: + void + init (shared_ptr, shared_ptr); + + // @@ TODO Archive the tenant. + // + void + cancel (/*...*/); + + private: + shared_ptr options_; + shared_ptr build_db_; + }; +} + +#endif // MOD_CI_COMMON_HXX -- cgit v1.1