diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-02-22 11:17:25 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-02-22 11:18:08 +0300 |
commit | d4900d85f7a5d791f89821713d02d3dd19361044 (patch) | |
tree | 4e7a1cc241d108c89779df9ec62f144a62937c17 /load/load.cxx | |
parent | f5ed92e8dbdfd751276ebb054669ca649b28e43c (diff) |
Add support for tenant-associated service notifications
Diffstat (limited to 'load/load.cxx')
-rw-r--r-- | load/load.cxx | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/load/load.cxx b/load/load.cxx index b644a3a..56e4e19 100644 --- a/load/load.cxx +++ b/load/load.cxx @@ -1492,6 +1492,40 @@ try throw failed (); } + // Verify the --service-* options. + // + if (ops.service_id_specified ()) + { + if (!ops.tenant_specified ()) + { + cerr << "error: --service-id requires --tenant" << endl; + throw failed (); + } + + if (ops.service_type ().empty ()) + { + cerr << "error: --service-id requires --service-type" + << endl; + throw failed (); + } + } + else + { + if (ops.service_type_specified ()) + { + cerr << "error: --service-type requires --service-id" + << endl; + throw failed (); + } + + if (ops.service_data_specified ()) + { + cerr << "error: --service-data requires --service-id" + << endl; + throw failed (); + } + } + // Parse and validate overrides, if specified. // // Note that here we make sure that the overrides manifest is valid. @@ -1591,11 +1625,30 @@ try // Persist the tenant. // + // Note that if the tenant service is specified and some tenant with the + // same service id and type is already persisted, then we will end up with + // the `object already persistent` error and terminate with the exit code + // 1 (fatal error). We could potentially dedicate a special exit code for + // such a case, so that the caller may recognize it and behave accordingly + // (CI request handler can treat it as a client error rather than an + // internal error, etc). However, let's first see if it ever becomes a + // problem. + // + optional<tenant_service> service; + + if (ops.service_id_specified ()) + service = tenant_service (ops.service_id (), + ops.service_type (), + (ops.service_data_specified () + ? ops.service_data () + : optional<string> ())); + db.persist (tenant (tnt, ops.private_ (), (ops.interactive_specified () ? ops.interactive () - : optional<string> ()))); + : optional<string> ()), + move (service))); // On the first pass over the internal repositories we load their // certificate information and packages. |