Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const projectUtils_1 = require("../projectUtils");
  6. const containerCleaner_1 = require("../deploy/functions/containerCleaner");
  7. const prompt_1 = require("../prompt");
  8. const requirePermissions_1 = require("../requirePermissions");
  9. const error_1 = require("../error");
  10. function getConfirmationMessage(paths) {
  11. let message = "You are about to delete all images in the following directories:\n\n";
  12. for (const path of paths) {
  13. message += `${path}\n`;
  14. }
  15. message += "\nAre you sure?\n";
  16. return message;
  17. }
  18. exports.command = new command_1.Command("functions:deletegcfartifacts")
  19. .description("Deletes all artifacts created by Google Cloud Functions on Google Container Registry.")
  20. .option("--regions <regions>", "Specify regions of artifacts to be deleted. " +
  21. "If omitted, artifacts from all regions will be deleted. " +
  22. "<regions> is a Google defined region list, e.g. us-central1,us-east1,europe-west2.")
  23. .before(requirePermissions_1.requirePermissions, ["storage.objects.delete"])
  24. .action(async (options) => {
  25. const projectId = (0, projectUtils_1.needProjectId)(options);
  26. const regions = options.regions ? options.regions.split(",") : undefined;
  27. const dockerHelper = {};
  28. try {
  29. const gcfPaths = await (0, containerCleaner_1.listGcfPaths)(projectId, regions, dockerHelper);
  30. const confirmDeletion = await (0, prompt_1.promptOnce)({
  31. type: "confirm",
  32. name: "force",
  33. default: false,
  34. message: getConfirmationMessage(gcfPaths),
  35. }, options);
  36. if (!confirmDeletion) {
  37. throw new error_1.FirebaseError("Command aborted.", { exit: 1 });
  38. }
  39. await (0, containerCleaner_1.deleteGcfArtifacts)(projectId, regions, dockerHelper);
  40. }
  41. catch (err) {
  42. throw new error_1.FirebaseError("Command failed.", { original: err });
  43. }
  44. });