GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.6 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.deploy = void 0;
  4. const tasks = require("./tasks");
  5. const queue_1 = require("../../throttler/queue");
  6. const error_1 = require("../../error");
  7. const errors_1 = require("./errors");
  8. const projectUtils_1 = require("../../projectUtils");
  9. const provisioningHelper_1 = require("../../extensions/provisioningHelper");
  10. const secrets_1 = require("./secrets");
  11. const validate_1 = require("./validate");
  12. async function deploy(context, options, payload) {
  13. var _a, _b, _c, _d, _e, _f, _g, _h, _j;
  14. const projectId = (0, projectUtils_1.needProjectId)(options);
  15. await (0, validate_1.checkBilling)(projectId, options.nonInteractive);
  16. await (0, provisioningHelper_1.bulkCheckProductsProvisioned)(projectId, [
  17. ...((_a = payload.instancesToCreate) !== null && _a !== void 0 ? _a : []),
  18. ...((_b = payload.instancesToUpdate) !== null && _b !== void 0 ? _b : []),
  19. ...((_c = payload.instancesToConfigure) !== null && _c !== void 0 ? _c : []),
  20. ]);
  21. await (0, secrets_1.handleSecretParams)(payload, context.have, options.nonInteractive);
  22. const errorHandler = new errors_1.ErrorHandler();
  23. const validationQueue = new queue_1.default({
  24. retries: 5,
  25. concurrency: 5,
  26. handler: tasks.extensionsDeploymentHandler(errorHandler),
  27. });
  28. for (const create of (_e = (_d = payload.instancesToCreate) === null || _d === void 0 ? void 0 : _d.filter((i) => !!i.ref)) !== null && _e !== void 0 ? _e : []) {
  29. const task = tasks.createExtensionInstanceTask(projectId, create, true);
  30. void validationQueue.run(task);
  31. }
  32. for (const update of (_g = (_f = payload.instancesToUpdate) === null || _f === void 0 ? void 0 : _f.filter((i) => !!i.ref)) !== null && _g !== void 0 ? _g : []) {
  33. const task = tasks.updateExtensionInstanceTask(projectId, update, true);
  34. void validationQueue.run(task);
  35. }
  36. for (const configure of (_j = (_h = payload.instancesToConfigure) === null || _h === void 0 ? void 0 : _h.filter((i) => !!i.ref)) !== null && _j !== void 0 ? _j : []) {
  37. const task = tasks.configureExtensionInstanceTask(projectId, configure, true);
  38. void validationQueue.run(task);
  39. }
  40. const validationPromise = validationQueue.wait();
  41. validationQueue.process();
  42. validationQueue.close();
  43. await validationPromise;
  44. if (errorHandler.hasErrors()) {
  45. errorHandler.print();
  46. throw new error_1.FirebaseError(`Extensions deployment failed validation. No changes have been made to the Extension instances on ${projectId}`);
  47. }
  48. }
  49. exports.deploy = deploy;