// file : bbot/manifest -*- C++ -*- // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file #ifndef BBOT_MANIFEST #define BBOT_MANIFEST #include #include #include #include #include #include #include // version, repository_location #include #include namespace bbot { enum class machine_type {kvm, nspawn}; class LIBBBOT_EXPORT machine_manifest { public: // A "machine header". // std::string id; std::string name; std::string summary; butl::optional type; machine_manifest (std::string i, std::string n, std::string s) : id (std::move (i)), name (std::move (n)), summary (std::move (s)) {} public: machine_manifest () = default; // VC export. machine_manifest (butl::manifest_parser&, bool ignore_unknown = false); machine_manifest (butl::manifest_parser&, butl::manifest_name_value start, bool header_only = false, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; }; using machine_manifests = std::vector; class LIBBBOT_EXPORT task_request_manifest { public: std::string agent; // Agent's public key SHA256 fingerprint. // // @@ How the fingerpring for openssl public key will be produced? Seems // there is no "standard" for it. Possibly we will use the following // command result (plain SHA256). // // $ cat key.pub | openssl sha256 // std::string fingerprint; machine_manifests machines; // Only machine headers. public: task_request_manifest () = default; // VC export. task_request_manifest (butl::manifest_parser&, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; }; class LIBBBOT_EXPORT task_manifest { public: // Package to build. // std::string name; bpkg::version version; bpkg::repository_location repository; // Remote or absolute. // Build machine to use for building the package. // std::string machine; // Default for the machine if absent. // butl::optional target; // Build system configuration variables (in addition to build environment // configuration variables). // variables config; public: task_manifest () = default; // VC export. task_manifest (butl::manifest_parser&, bool ignore_unknown = false); task_manifest (butl::manifest_parser&, butl::manifest_name_value start, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; }; class LIBBBOT_EXPORT task_response_manifest { public: // If empty then no task available. // std::string session; // Challenge and task are absent if session is empty. // butl::optional challenge; butl::optional task; public: task_response_manifest () = default; // VC export. task_response_manifest (butl::manifest_parser&, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; }; // Build task or operation result status. // enum class result_status: std::uint8_t { // The order of the enumerators is arranged so that their integral values // indicate whether one "overrides" the other in the "merge" operator| // (see below). // success, warning, error, abort, abnormal }; std::ostream& operator<< (std::ostream&, result_status); inline result_status& operator |= (result_status& l, result_status r) { if (static_cast (r) > static_cast (l)) l = r; return l; } struct operation_result { std::string operation; // "configure", "update", "test", etc. result_status status; std::string log; }; using operation_results = std::vector; class LIBBBOT_EXPORT result_manifest { public: // Built package. // std::string name; bpkg::version version; result_status status; // Ordered (ascending) by operation value. May not contain all the // operations if the task failed in the middle, but should have no gaps // (operation can not start unless all previous ones succeeded). // operation_results results; result_manifest () = default; // VC export. result_manifest (butl::manifest_parser&, bool ignore_unknown = false); result_manifest (butl::manifest_parser&, butl::manifest_name_value start, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; }; class LIBBBOT_EXPORT result_request_manifest { public: std::string session; // The task response session. std::string challenge; // The answer to challenge in the task response. result_manifest result; public: result_request_manifest () = default; // VC export. result_request_manifest (butl::manifest_parser&, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; }; } #endif // BBOT_MANIFEST