@catladder/cli 0.0.0-fix-config-move-not-working-again-8ba85846 → 0.0.0-fix-handle-missing-cloud-sql-proxy-command-error-and-show-nice-17045900
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/catenv/index.js +336 -135
- package/dist/bundles/cli/index.js +479 -192
- package/dist/cli/src/apps/catenv/printVariables.js +4 -1
- package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
- package/dist/cli/src/apps/catenv/utils.d.ts +6 -2
- package/dist/cli/src/apps/catenv/utils.js +4 -2
- package/dist/cli/src/apps/catenv/utils.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js +84 -51
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/cli/src/utils/log.d.ts +65 -1
- package/dist/cli/src/utils/log.js +66 -8
- package/dist/cli/src/utils/log.js.map +1 -1
- package/dist/cli/src/utils/preferences.js +9 -11
- package/dist/cli/src/utils/preferences.js.map +1 -1
- package/dist/pipeline/src/bash/bashEscape.d.ts +4 -1
- package/dist/pipeline/src/bash/bashEscape.js +4 -2
- package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
- package/dist/pipeline/src/context/getEnvConfig.js +14 -2
- package/dist/pipeline/src/context/getEnvConfig.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +5 -3
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +18 -107
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +4 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +85 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.d.ts +3 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +136 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +5 -3
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +5 -3
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/index.js +6 -2
- package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.d.ts +6 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js +11 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/jobName.d.ts +5 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js +7 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js.map +1 -1
- package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +99 -1
- package/dist/pipeline/src/deploy/types/index.d.ts +1 -0
- package/dist/pipeline/src/deploy/types/index.js +7 -1
- package/dist/pipeline/src/deploy/types/index.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +11 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/catenv/printVariables.ts +4 -1
- package/src/apps/catenv/utils.ts +12 -3
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +130 -66
- package/src/utils/log.ts +104 -8
- package/src/utils/preferences.ts +13 -23
|
@@ -982,61 +982,30 @@ exports["default"] = async (vorpal) => vorpal
|
|
|
982
982
|
/***/ }),
|
|
983
983
|
|
|
984
984
|
/***/ 102:
|
|
985
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__)
|
|
985
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
986
986
|
|
|
987
987
|
"use strict";
|
|
988
988
|
|
|
989
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
990
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
991
|
+
};
|
|
989
992
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
990
993
|
const pipeline_1 = __nccwpck_require__(10603);
|
|
994
|
+
const clipboardy_1 = __importDefault(__nccwpck_require__(89881));
|
|
991
995
|
const getProjectConfig_1 = __nccwpck_require__(12145);
|
|
992
996
|
const autocompletions_1 = __nccwpck_require__(39855);
|
|
993
997
|
const startProxy_1 = __nccwpck_require__(90742);
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
.action(async function ({ envComponent }) {
|
|
998
|
-
var _a, _b;
|
|
999
|
-
const { env, componentName } = (0, getProjectConfig_1.parseChoice)(envComponent);
|
|
1000
|
-
if (!componentName) {
|
|
1001
|
-
this.log("need componentName");
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
|
|
1005
|
-
let proxyInfo;
|
|
1006
|
-
if (env === "review") {
|
|
1007
|
-
vorpal.log("⚠️ connection string does not include mr information on review environments");
|
|
1008
|
-
}
|
|
998
|
+
const log_1 = __nccwpck_require__(66921);
|
|
999
|
+
const getProxyInfo = (context) => {
|
|
1000
|
+
var _a, _b, _c, _d;
|
|
1009
1001
|
if ((0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
|
|
1010
|
-
|
|
1002
|
+
return getProxyInfoForKubernetes(this, context);
|
|
1011
1003
|
}
|
|
1012
1004
|
else if ((0, pipeline_1.isOfDeployType)((_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config, "google-cloudrun")) {
|
|
1013
|
-
|
|
1005
|
+
return getProxyInfoForCloudRun(this, context);
|
|
1014
1006
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
// skynet-164509:europe-west6:pvl-cyclomania-review=tcp:5432
|
|
1019
|
-
const { DB_PASSWORD, DB_NAME, DB_USER, instanceName } = proxyInfo;
|
|
1020
|
-
const { localPort } = await this.prompt({
|
|
1021
|
-
type: "number",
|
|
1022
|
-
name: "localPort",
|
|
1023
|
-
default: "54320",
|
|
1024
|
-
message: "Local port: ",
|
|
1025
|
-
});
|
|
1026
|
-
this.log("");
|
|
1027
|
-
this.log(`postgres-PW: ${DB_PASSWORD}`);
|
|
1028
|
-
this.log("");
|
|
1029
|
-
this.log("connection strings:");
|
|
1030
|
-
this.log("");
|
|
1031
|
-
this.log(`DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}?schema=public`);
|
|
1032
|
-
this.log("");
|
|
1033
|
-
this.log(`DATABASE_JDBC_URL=jdbc:postgresql://localhost:${localPort}/${DB_NAME}?schema=public&user=${DB_USER}&password=${DB_PASSWORD}`);
|
|
1034
|
-
this.log("");
|
|
1035
|
-
await (0, startProxy_1.startCloudSqlProxyInCurrentShell)({
|
|
1036
|
-
instanceName,
|
|
1037
|
-
localPort,
|
|
1038
|
-
});
|
|
1039
|
-
});
|
|
1007
|
+
throw new Error(`unsupported environment: ${(_d = (_c = context.deploy) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.type}`);
|
|
1008
|
+
};
|
|
1040
1009
|
const getProxyInfoForKubernetes = async (vorpal, context) => {
|
|
1041
1010
|
var _a, _b;
|
|
1042
1011
|
if (!(0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
|
|
@@ -1056,22 +1025,86 @@ const getProxyInfoForKubernetes = async (vorpal, context) => {
|
|
|
1056
1025
|
};
|
|
1057
1026
|
};
|
|
1058
1027
|
const getProxyInfoForCloudRun = async (vorpal, context) => {
|
|
1059
|
-
var _a, _b, _c, _d, _e;
|
|
1028
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1060
1029
|
if (!(0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "google-cloudrun") ||
|
|
1061
1030
|
!((_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config.cloudSql)) {
|
|
1062
|
-
|
|
1031
|
+
const deployType = (0, pipeline_1.getDeployConfigType)((_c = context.deploy) === null || _c === void 0 ? void 0 : _c.config);
|
|
1032
|
+
const errorMessage = deployType === "google-cloudrun"
|
|
1033
|
+
? `DeployConfig is missing the cloudSql property`
|
|
1034
|
+
: `Unsupported DeployConfig type: ${deployType}`;
|
|
1035
|
+
(0, log_1.logError)(vorpal, errorMessage);
|
|
1036
|
+
throw new Error(errorMessage);
|
|
1063
1037
|
}
|
|
1064
1038
|
const envVars = await (0, getProjectConfig_1.getEnvVarsResolved)(vorpal, context.env, context.name);
|
|
1065
|
-
const DB_PASSWORD = (_c = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) === null || _c === void 0 ? void 0 : _c.toString();
|
|
1066
|
-
const DB_USER = (_d = envVars === null || envVars === void 0 ? void 0 : envVars.DB_USER) === null || _d === void 0 ? void 0 : _d.toString();
|
|
1067
|
-
const DB_NAME = context.environment.envVars.DB_NAME.toString();
|
|
1068
1039
|
return {
|
|
1069
|
-
instanceName: (
|
|
1070
|
-
DB_PASSWORD,
|
|
1071
|
-
DB_NAME,
|
|
1072
|
-
DB_USER,
|
|
1040
|
+
instanceName: (_d = context.deploy) === null || _d === void 0 ? void 0 : _d.config.cloudSql.instanceConnectionName,
|
|
1041
|
+
DB_PASSWORD: (_e = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) === null || _e === void 0 ? void 0 : _e.toString(),
|
|
1042
|
+
DB_NAME: context.environment.envVars.DB_NAME.toString(),
|
|
1043
|
+
DB_USER: (_f = envVars === null || envVars === void 0 ? void 0 : envVars.DB_USER) === null || _f === void 0 ? void 0 : _f.toString(),
|
|
1073
1044
|
};
|
|
1074
1045
|
};
|
|
1046
|
+
const getDbUrl = ({ DB_PASSWORD, DB_NAME, DB_USER }, localPort, additional = "") => `DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}${additional}"`;
|
|
1047
|
+
const getJdbcUrl = ({ DB_PASSWORD, DB_NAME, DB_USER }, localPort) => `DATABASE_JDBC_URL="jdbc:postgresql://localhost:${localPort}/${DB_NAME}?schema=public&user=${DB_USER}&password=${DB_PASSWORD}"`;
|
|
1048
|
+
exports["default"] = async (vorpal) => vorpal
|
|
1049
|
+
.command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
|
|
1050
|
+
.autocomplete(await (0, autocompletions_1.envAndComponents)())
|
|
1051
|
+
.action(async function ({ envComponent }) {
|
|
1052
|
+
const { env, componentName } = (0, getProjectConfig_1.parseChoice)(envComponent);
|
|
1053
|
+
if (!componentName) {
|
|
1054
|
+
(0, log_1.logWarning)(this, "need componentName");
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
|
|
1058
|
+
if (env === "review") {
|
|
1059
|
+
(0, log_1.logWarning)(this, "connection string does not include mr information on review environments");
|
|
1060
|
+
}
|
|
1061
|
+
const { localPort } = await this.prompt({
|
|
1062
|
+
type: "number",
|
|
1063
|
+
name: "localPort",
|
|
1064
|
+
default: "54320",
|
|
1065
|
+
message: "Local port: ",
|
|
1066
|
+
});
|
|
1067
|
+
const proxyInfo = await getProxyInfo(context);
|
|
1068
|
+
/**
|
|
1069
|
+
* Env variables for libpq (e.g. psql client)
|
|
1070
|
+
* https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS
|
|
1071
|
+
*/
|
|
1072
|
+
const psqlEnvVars = {
|
|
1073
|
+
PGPASSWORD: proxyInfo.DB_PASSWORD,
|
|
1074
|
+
PGUSER: proxyInfo.DB_USER,
|
|
1075
|
+
PGDATABASE: proxyInfo.DB_NAME,
|
|
1076
|
+
PGHOST: "localhost",
|
|
1077
|
+
PGPORT: localPort,
|
|
1078
|
+
};
|
|
1079
|
+
const lipbqEnvVarDeclarations = Object.entries(psqlEnvVars).map(([key, value]) => `${key}="${value}"`);
|
|
1080
|
+
const dbUrl = getDbUrl(proxyInfo, localPort);
|
|
1081
|
+
const jdbcUrl = getJdbcUrl(proxyInfo, localPort);
|
|
1082
|
+
clipboardy_1.default.writeSync([
|
|
1083
|
+
"",
|
|
1084
|
+
"## CloudSQL proxy connection .env variables",
|
|
1085
|
+
dbUrl,
|
|
1086
|
+
jdbcUrl,
|
|
1087
|
+
"## DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",
|
|
1088
|
+
`# ${getDbUrl(proxyInfo, localPort, `?schema=public`)}`,
|
|
1089
|
+
"## Env variables for libpq (e.g. psql client https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS)",
|
|
1090
|
+
...lipbqEnvVarDeclarations,
|
|
1091
|
+
"",
|
|
1092
|
+
].join("\n"));
|
|
1093
|
+
(0, log_1.logLines)(this, null, "Connection strings env variables DATABASE_URL and those for the 'psql' client (copied to your clipboard for .env file):", dbUrl, jdbcUrl, ...lipbqEnvVarDeclarations, null, "DATABASE_URL with schema=public parameter (e. g. Prisma requires this):", getDbUrl(proxyInfo, localPort, `?schema=public`), null);
|
|
1094
|
+
try {
|
|
1095
|
+
await (0, startProxy_1.startCloudSqlProxyInCurrentShell)({
|
|
1096
|
+
instanceName: proxyInfo.instanceName,
|
|
1097
|
+
localPort,
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
catch (error) {
|
|
1101
|
+
if (!(error instanceof Error))
|
|
1102
|
+
throw error;
|
|
1103
|
+
if (error.message !== startProxy_1.ERROR_NOT_INSTALLED)
|
|
1104
|
+
throw error;
|
|
1105
|
+
(0, log_1.logError)(this, error.message, null, "Please install the Cloud SQL Auth Proxy from:", `https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#install`, null);
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1075
1108
|
//# sourceMappingURL=commandCloudSqlProxy.js.map
|
|
1076
1109
|
|
|
1077
1110
|
/***/ }),
|
|
@@ -3528,17 +3561,75 @@ exports.upsertAllVariables = upsertAllVariables;
|
|
|
3528
3561
|
"use strict";
|
|
3529
3562
|
|
|
3530
3563
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3531
|
-
exports.logError = void 0;
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3564
|
+
exports.logWarning = exports.logError = exports.logLines = void 0;
|
|
3565
|
+
/**
|
|
3566
|
+
* Logs multiple lines using the log method of the provided {@link LoggerCmdInstance}.
|
|
3567
|
+
*
|
|
3568
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
3569
|
+
*
|
|
3570
|
+
* @param cmd - The logger instance to use. If `null` or `undefined`, `console` will be used.
|
|
3571
|
+
*
|
|
3572
|
+
* @example
|
|
3573
|
+
* ```ts
|
|
3574
|
+
* logLines(cmd, "line 1", "line 2", null, "line 3");
|
|
3575
|
+
* logLines(cmd, ...linesArray); // arrays can be spread into the function
|
|
3576
|
+
* logLines(cmd, linesArray); // but it will flatten the plain array for convenience
|
|
3577
|
+
* ```
|
|
3578
|
+
*/
|
|
3579
|
+
function logLines(cmd = console, ...lines) {
|
|
3580
|
+
const logger = cmd !== null && cmd !== void 0 ? cmd : console;
|
|
3581
|
+
for (const line of lines.flat()) {
|
|
3582
|
+
if (line === null || line === undefined) {
|
|
3583
|
+
logger.log("");
|
|
3584
|
+
}
|
|
3585
|
+
else {
|
|
3586
|
+
logger.log(line);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
exports.logLines = logLines;
|
|
3591
|
+
/**
|
|
3592
|
+
* Logs an error message using the log method of the provided {@link LoggerCmdInstance}.
|
|
3593
|
+
*
|
|
3594
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
3595
|
+
*
|
|
3596
|
+
* @example
|
|
3597
|
+
* ```ts
|
|
3598
|
+
* logError(cmd, "Message");
|
|
3599
|
+
* logError(cmd, "Message", "Additional message");
|
|
3600
|
+
* logError(cmd, "Message", "Additional message", "Another additional message line");
|
|
3601
|
+
* logError(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
3602
|
+
* logError(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
3603
|
+
* ```
|
|
3604
|
+
*/
|
|
3605
|
+
const logError = (cmd = console, message, ...additionalMessages) => {
|
|
3606
|
+
logLines(cmd, null, `[ERROR] 🙀 :${message}`, null);
|
|
3607
|
+
if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
|
|
3608
|
+
logLines(cmd, ...additionalMessages.flat(), null);
|
|
3539
3609
|
}
|
|
3540
3610
|
};
|
|
3541
3611
|
exports.logError = logError;
|
|
3612
|
+
/**
|
|
3613
|
+
* Logs a warning message using the log method of the provided {@link LoggerCmdInstance}.
|
|
3614
|
+
*
|
|
3615
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
3616
|
+
*
|
|
3617
|
+
* @example
|
|
3618
|
+
* ```ts
|
|
3619
|
+
* logWarning(cmd, "Message");
|
|
3620
|
+
* logWarning(cmd, "Message", "Additional message");
|
|
3621
|
+
* logWarning(cmd, "Message", "Additional message", "Another additional message line");
|
|
3622
|
+
* logWarning(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
3623
|
+
* logWarning(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
3624
|
+
* ```
|
|
3625
|
+
*/
|
|
3626
|
+
const logWarning = (cmd = console, message, ...additionalMessages) => {
|
|
3627
|
+
logLines(cmd, `[WARNING] ⚠️: ${message}`);
|
|
3628
|
+
if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
|
|
3629
|
+
logLines(cmd, ...additionalMessages.flat(), null);
|
|
3630
|
+
}
|
|
3631
|
+
};
|
|
3632
|
+
exports.logWarning = logWarning;
|
|
3542
3633
|
//# sourceMappingURL=log.js.map
|
|
3543
3634
|
|
|
3544
3635
|
/***/ }),
|
|
@@ -3613,21 +3704,19 @@ const yaml_1 = __nccwpck_require__(68033);
|
|
|
3613
3704
|
const legacyPreferencesPath = (0, path_1.join)((0, os_1.homedir)(), ".catladder/preferences.yml");
|
|
3614
3705
|
const preferencesPath = (0, path_1.join)((0, os_1.homedir)(), ".config/catladder/preferences.yml");
|
|
3615
3706
|
const ensurePreferencesFile = async () => {
|
|
3616
|
-
if ((0, fs_1.existsSync)(legacyPreferencesPath) && !(0, fs_1.existsSync)(preferencesPath)) {
|
|
3617
|
-
await (0, promises_1.mkdir)((0, path_1.dirname)(preferencesPath), { recursive: true, mode: 0o700 });
|
|
3618
|
-
await (0, promises_1.cp)(legacyPreferencesPath, preferencesPath);
|
|
3619
|
-
await (0, promises_1.chmod)(preferencesPath, 0o600);
|
|
3620
|
-
await (0, promises_1.cp)(preferencesPath, (0, path_1.join)((0, path_1.dirname)(preferencesPath), "old_preferences_backup.yml"));
|
|
3621
|
-
return;
|
|
3622
|
-
}
|
|
3623
3707
|
if ((0, fs_1.existsSync)(preferencesPath)) {
|
|
3624
3708
|
return;
|
|
3625
3709
|
}
|
|
3626
3710
|
await (0, promises_1.mkdir)((0, path_1.dirname)(preferencesPath), { recursive: true, mode: 0o700 });
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3711
|
+
if (!(0, fs_1.existsSync)(legacyPreferencesPath)) {
|
|
3712
|
+
return (0, promises_1.writeFile)(preferencesPath, "---\n{}", {
|
|
3713
|
+
encoding: "utf-8",
|
|
3714
|
+
mode: 0o600,
|
|
3715
|
+
});
|
|
3716
|
+
}
|
|
3717
|
+
await (0, promises_1.cp)(legacyPreferencesPath, preferencesPath);
|
|
3718
|
+
await (0, promises_1.chmod)(preferencesPath, 0o600);
|
|
3719
|
+
await (0, promises_1.cp)(preferencesPath, (0, path_1.join)((0, path_1.dirname)(preferencesPath), "old_preferences_backup.yml"));
|
|
3631
3720
|
};
|
|
3632
3721
|
const loadPreferences = async () => {
|
|
3633
3722
|
await ensurePreferencesFile();
|
|
@@ -3898,14 +3987,16 @@ exports.escapeSingleQuotes = escapeSingleQuotes;
|
|
|
3898
3987
|
*
|
|
3899
3988
|
* - other languages are currently only partially supported, since most .env implementations are slightly different
|
|
3900
3989
|
*/
|
|
3901
|
-
const escapeForDotEnv = (value
|
|
3990
|
+
const escapeForDotEnv = (value, options = {
|
|
3991
|
+
quoteMode: "auto",
|
|
3992
|
+
}) => {
|
|
3902
3993
|
if (value === undefined || value === null) {
|
|
3903
3994
|
return "";
|
|
3904
3995
|
}
|
|
3905
3996
|
if (typeof value === "string") {
|
|
3906
3997
|
// if string contains newlines, we need to wrap it in quotes
|
|
3907
3998
|
// we additionaly escape newlines, that give best compatibility
|
|
3908
|
-
if (value.includes("\n")) {
|
|
3999
|
+
if (options.quoteMode === "always" || value.includes("\n")) {
|
|
3909
4000
|
const newlinesReplaces = value.replace(/\n/g, "\\n");
|
|
3910
4001
|
// default to ", but if this is not possible, we try to use ' or `
|
|
3911
4002
|
const quote = value.includes(`"`)
|
|
@@ -5934,7 +6025,7 @@ exports.getBuildInfoVariables = getBuildInfoVariables;
|
|
|
5934
6025
|
|
|
5935
6026
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5936
6027
|
exports.getEnvConfig = void 0;
|
|
5937
|
-
const
|
|
6028
|
+
const lodash_1 = __nccwpck_require__(23255);
|
|
5938
6029
|
const getEnvConfig = (config, componentName, env) => {
|
|
5939
6030
|
var _a, _b;
|
|
5940
6031
|
const defaultConfig = config.components[componentName];
|
|
@@ -5946,7 +6037,19 @@ const getEnvConfig = (config, componentName, env) => {
|
|
|
5946
6037
|
// env is disabled, still return the default config
|
|
5947
6038
|
return defaultConfig;
|
|
5948
6039
|
}
|
|
5949
|
-
|
|
6040
|
+
/**
|
|
6041
|
+
* env config is merged with default. Arrays are not merged.
|
|
6042
|
+
* you can customize this by providing a function that takes the default value as argument
|
|
6043
|
+
*/
|
|
6044
|
+
return (0, lodash_1.mergeWith)({}, defaultConfig, envCustomizations, (defaultValue, customValue) => {
|
|
6045
|
+
// check if custom value is a function (and default is not),
|
|
6046
|
+
// we currently don't have config options that are functions, but we might in the future
|
|
6047
|
+
if (typeof customValue === "function" &&
|
|
6048
|
+
typeof defaultValue !== "function") {
|
|
6049
|
+
return customValue(defaultValue);
|
|
6050
|
+
}
|
|
6051
|
+
return undefined;
|
|
6052
|
+
});
|
|
5950
6053
|
};
|
|
5951
6054
|
exports.getEnvConfig = getEnvConfig;
|
|
5952
6055
|
//# sourceMappingURL=getEnvConfig.js.map
|
|
@@ -6780,69 +6883,35 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
|
|
|
6780
6883
|
"use strict";
|
|
6781
6884
|
|
|
6782
6885
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6783
|
-
exports.
|
|
6886
|
+
exports.getCloudRunJobsWithNames = exports.getJobCreateScripts = exports.getDeleteJobsScripts = void 0;
|
|
6887
|
+
const getLabels_1 = __nccwpck_require__(30920);
|
|
6888
|
+
const utils_1 = __nccwpck_require__(32497);
|
|
6784
6889
|
const createArgsString_1 = __nccwpck_require__(49598);
|
|
6785
6890
|
const jobName_1 = __nccwpck_require__(9626);
|
|
6786
6891
|
const common_1 = __nccwpck_require__(73325);
|
|
6787
|
-
const getLabels_1 = __nccwpck_require__(30920);
|
|
6788
|
-
const volumes_1 = __nccwpck_require__(60847);
|
|
6789
6892
|
const constants_1 = __nccwpck_require__(38865);
|
|
6790
|
-
const
|
|
6791
|
-
const
|
|
6792
|
-
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
6793
|
-
const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
6794
|
-
return `${(0, common_1.gcloudRunCmd)()} jobs execute ${jobName.toString()} ${commonArgsString}${wait ? " --wait" : ""}`;
|
|
6795
|
-
};
|
|
6796
|
-
const getDeleteSchedulesScripts = (context) => {
|
|
6797
|
-
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6798
|
-
const schedules = getSchedules(context);
|
|
6799
|
-
const argsString = (0, createArgsString_1.createArgsString)({
|
|
6800
|
-
project: deployConfig.projectId,
|
|
6801
|
-
location: deployConfig.region,
|
|
6802
|
-
});
|
|
6803
|
-
return schedules
|
|
6804
|
-
.map(({ name }) => {
|
|
6805
|
-
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
|
|
6806
|
-
})
|
|
6807
|
-
.flat();
|
|
6808
|
-
};
|
|
6809
|
-
exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
|
|
6893
|
+
const volumes_1 = __nccwpck_require__(60847);
|
|
6894
|
+
const onDeploy_1 = __nccwpck_require__(2358);
|
|
6810
6895
|
const getDeleteJobsScripts = (context) => {
|
|
6811
6896
|
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
6812
6897
|
const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
6813
|
-
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
6814
|
-
return jobsWithNames.flatMap(({
|
|
6898
|
+
const jobsWithNames = (0, exports.getCloudRunJobsWithNames)(context);
|
|
6899
|
+
return jobsWithNames.flatMap(({ fullJobName }) => [
|
|
6815
6900
|
// first delete all job executions. Otherwise delete might fail if one of those is still running
|
|
6816
|
-
`${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${
|
|
6817
|
-
`${(0, common_1.gcloudRunCmd)()} jobs delete ${
|
|
6901
|
+
`${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${fullJobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
|
|
6902
|
+
`${(0, common_1.gcloudRunCmd)()} jobs delete ${fullJobName} ${commonArgsString}`,
|
|
6818
6903
|
]);
|
|
6819
6904
|
};
|
|
6820
6905
|
exports.getDeleteJobsScripts = getDeleteJobsScripts;
|
|
6821
|
-
const
|
|
6822
|
-
|
|
6823
|
-
return jobsWithNames
|
|
6824
|
-
.filter(({ job }) => job.when === when)
|
|
6825
|
-
.map(({ jobName, job }) => {
|
|
6826
|
-
var _a;
|
|
6827
|
-
// always wait for completion for preStop and postStop jobs
|
|
6828
|
-
// since stop will delete the jobs afterwards, so they will fail
|
|
6829
|
-
const waitForCompletion = ["preStop", "postStop"].includes(when)
|
|
6830
|
-
? true
|
|
6831
|
-
: "waitForCompletion" in job
|
|
6832
|
-
? ((_a = job.waitForCompletion) !== null && _a !== void 0 ? _a : false)
|
|
6833
|
-
: false;
|
|
6834
|
-
return getJobRunScriptForJob(context, jobName, waitForCompletion);
|
|
6835
|
-
});
|
|
6836
|
-
};
|
|
6837
|
-
exports.getJobRunScripts = getJobRunScripts;
|
|
6838
|
-
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
|
|
6839
|
-
var _a, _b, _c, _d;
|
|
6906
|
+
const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(context).map(({ job, fullJobName }, jobIndex) => {
|
|
6907
|
+
var _a, _b, _c, _d, _e;
|
|
6840
6908
|
const commandArray = Array.isArray(job.command)
|
|
6841
6909
|
? job.command
|
|
6842
6910
|
: job.command.split(" ");
|
|
6843
6911
|
const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
|
|
6844
6912
|
const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
|
|
6845
6913
|
command: `"${commandArray.join(",")}"`,
|
|
6914
|
+
args: (0, onDeploy_1.getCloudRunJobArgsArg)(job.args),
|
|
6846
6915
|
labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
|
|
6847
6916
|
image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
|
|
6848
6917
|
project,
|
|
@@ -6852,7 +6921,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
6852
6921
|
parallelism: (_c = job.parallelism) !== null && _c !== void 0 ? _c : 1,
|
|
6853
6922
|
"task-timeout": (_d = job.timeout) !== null && _d !== void 0 ? _d : "10m",
|
|
6854
6923
|
"env-vars-file": constants_1.ENV_VARS_FILENAME,
|
|
6855
|
-
"max-retries": 0,
|
|
6924
|
+
"max-retries": (_e = job.maxRetries) !== null && _e !== void 0 ? _e : 0,
|
|
6856
6925
|
...deployArgs,
|
|
6857
6926
|
// network
|
|
6858
6927
|
"vpc-connector": job === null || job === void 0 ? void 0 : job.vpcConnector,
|
|
@@ -6864,7 +6933,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
6864
6933
|
jobIndex === 0
|
|
6865
6934
|
? `exist_job_names="$(\n ${(0, common_1.gcloudRunCmd)()} jobs list --filter='metadata.name ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --project='${project}' --region='${region}'\n)"`
|
|
6866
6935
|
: null,
|
|
6867
|
-
`current_job_name="${
|
|
6936
|
+
`current_job_name="${fullJobName}"`,
|
|
6868
6937
|
'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
|
|
6869
6938
|
` ${(0, common_1.gcloudRunCmd)()} jobs update "$current_job_name" ${commonDeployArgsString}`,
|
|
6870
6939
|
"else",
|
|
@@ -6875,75 +6944,20 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
6875
6944
|
.join("\n");
|
|
6876
6945
|
});
|
|
6877
6946
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
6878
|
-
const getCreateScheduleScripts = (context) => {
|
|
6879
|
-
const schedules = getSchedules(context);
|
|
6880
|
-
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6881
|
-
return schedules.map((scheduler, jobIndex) => {
|
|
6882
|
-
var _a;
|
|
6883
|
-
const uri = getSchedulerUrl(scheduler, context);
|
|
6884
|
-
const argsString = (0, createArgsString_1.createArgsString)({
|
|
6885
|
-
project,
|
|
6886
|
-
location,
|
|
6887
|
-
uri: `"$current_job_uri"`,
|
|
6888
|
-
"http-method": "POST",
|
|
6889
|
-
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
6890
|
-
schedule: `"${scheduler.schedule}"`,
|
|
6891
|
-
"max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
6892
|
-
});
|
|
6893
|
-
return [
|
|
6894
|
-
jobIndex === 0
|
|
6895
|
-
? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
|
|
6896
|
-
: null,
|
|
6897
|
-
`current_job_uri="${uri}"`,
|
|
6898
|
-
`current_scheduler_name="${scheduler.name}"`,
|
|
6899
|
-
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
6900
|
-
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
6901
|
-
`else`,
|
|
6902
|
-
` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
|
|
6903
|
-
`fi`,
|
|
6904
|
-
]
|
|
6905
|
-
.filter(utils_1.notNil)
|
|
6906
|
-
.join("\n");
|
|
6907
|
-
});
|
|
6908
|
-
};
|
|
6909
|
-
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
6910
|
-
const getSchedulerUrl = (scheduler, context) => {
|
|
6911
|
-
if (scheduler.type === "cloudRunJob") {
|
|
6912
|
-
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6913
|
-
const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
|
|
6914
|
-
return `${uriBase}/${scheduler.jobName}:run`;
|
|
6915
|
-
}
|
|
6916
|
-
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
6917
|
-
};
|
|
6918
|
-
const getSchedules = (context) => {
|
|
6919
|
-
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
6920
|
-
return jobsWithNames
|
|
6921
|
-
.filter((entry) => entry.job.when === "schedule")
|
|
6922
|
-
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
6923
|
-
const schedulerName = jobName.concat("-scheduler");
|
|
6924
|
-
return {
|
|
6925
|
-
name: schedulerName,
|
|
6926
|
-
maxRetryAttempts,
|
|
6927
|
-
schedule,
|
|
6928
|
-
type: "cloudRunJob",
|
|
6929
|
-
jobName,
|
|
6930
|
-
};
|
|
6931
|
-
});
|
|
6932
|
-
};
|
|
6933
6947
|
const getCloudRunJobsWithNames = (context) => {
|
|
6934
6948
|
var _a;
|
|
6935
6949
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6936
|
-
const getFullJobName = (name) => (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
|
|
6937
6950
|
const jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
|
|
6938
6951
|
// filter out disabled jobs
|
|
6939
6952
|
.filter((entry) => Boolean(entry[1]))
|
|
6940
|
-
.map(([
|
|
6941
|
-
|
|
6953
|
+
.map(([jobName, job]) => ({
|
|
6954
|
+
fullJobName: (0, jobName_1.getFullJobName)(context, jobName),
|
|
6942
6955
|
job,
|
|
6943
|
-
|
|
6956
|
+
jobName,
|
|
6944
6957
|
}));
|
|
6945
6958
|
return jobsWithNames;
|
|
6946
6959
|
};
|
|
6960
|
+
exports.getCloudRunJobsWithNames = getCloudRunJobsWithNames;
|
|
6947
6961
|
//# sourceMappingURL=cloudRunJobs.js.map
|
|
6948
6962
|
|
|
6949
6963
|
/***/ }),
|
|
@@ -7095,6 +7109,241 @@ exports.ENV_VARS_FILENAME = "____envvars.yaml";
|
|
|
7095
7109
|
|
|
7096
7110
|
/***/ }),
|
|
7097
7111
|
|
|
7112
|
+
/***/ 2358:
|
|
7113
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7114
|
+
|
|
7115
|
+
"use strict";
|
|
7116
|
+
|
|
7117
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7118
|
+
exports.getCloudRunJobArgsArg = exports.getOnDeployExecuteScript = void 0;
|
|
7119
|
+
const createArgsString_1 = __nccwpck_require__(49598);
|
|
7120
|
+
const jobName_1 = __nccwpck_require__(9626);
|
|
7121
|
+
const cloudRunJobs_1 = __nccwpck_require__(61224);
|
|
7122
|
+
const common_1 = __nccwpck_require__(73325);
|
|
7123
|
+
const getOnDeployExecuteScript = (context, when) => {
|
|
7124
|
+
const executes = getExecutes(context);
|
|
7125
|
+
return executes
|
|
7126
|
+
.filter(({ config }) => config.when === when)
|
|
7127
|
+
.map((execute) => {
|
|
7128
|
+
return getJobRunScriptForExecute(context, execute);
|
|
7129
|
+
});
|
|
7130
|
+
};
|
|
7131
|
+
exports.getOnDeployExecuteScript = getOnDeployExecuteScript;
|
|
7132
|
+
const getExecutes = (context) => {
|
|
7133
|
+
var _a;
|
|
7134
|
+
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
7135
|
+
return [
|
|
7136
|
+
...getLegacyExecutes(context),
|
|
7137
|
+
...Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
|
|
7138
|
+
if (!value || (value.when !== "schedule" && value.type !== "job")) {
|
|
7139
|
+
return [];
|
|
7140
|
+
}
|
|
7141
|
+
return [
|
|
7142
|
+
{
|
|
7143
|
+
jobName: key,
|
|
7144
|
+
config: value,
|
|
7145
|
+
},
|
|
7146
|
+
];
|
|
7147
|
+
}),
|
|
7148
|
+
];
|
|
7149
|
+
};
|
|
7150
|
+
const getLegacyExecutes = (context) => {
|
|
7151
|
+
const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
|
|
7152
|
+
return jobsWithNames.flatMap(({ jobName, job }) => {
|
|
7153
|
+
if (!job.when ||
|
|
7154
|
+
!["preDeploy", "postDeploy", "preStop", "postStop"].includes(job.when)) {
|
|
7155
|
+
return [];
|
|
7156
|
+
}
|
|
7157
|
+
return [
|
|
7158
|
+
{
|
|
7159
|
+
jobName,
|
|
7160
|
+
config: {
|
|
7161
|
+
job: jobName,
|
|
7162
|
+
type: "job",
|
|
7163
|
+
when: job.when,
|
|
7164
|
+
...(job.when === "preDeploy" || job.when === "postDeploy"
|
|
7165
|
+
? {
|
|
7166
|
+
waitForCompletion: job.waitForCompletion,
|
|
7167
|
+
}
|
|
7168
|
+
: {}),
|
|
7169
|
+
},
|
|
7170
|
+
},
|
|
7171
|
+
];
|
|
7172
|
+
});
|
|
7173
|
+
};
|
|
7174
|
+
const getJobRunScriptForExecute = (context, { jobName, config }) => {
|
|
7175
|
+
var _a;
|
|
7176
|
+
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
7177
|
+
// always wait for completion for preStop and postStop jobs
|
|
7178
|
+
// since stop will delete the jobs afterwards, so they will fail
|
|
7179
|
+
const waitForCompletion = ["preStop", "postStop"].includes(config.when)
|
|
7180
|
+
? true // always
|
|
7181
|
+
: "waitForCompletion" in config
|
|
7182
|
+
? ((_a = config.waitForCompletion) !== null && _a !== void 0 ? _a : false) // depends on config
|
|
7183
|
+
: false;
|
|
7184
|
+
const argString = (0, createArgsString_1.createArgsString)({
|
|
7185
|
+
...commonArgs,
|
|
7186
|
+
wait: waitForCompletion === true ? true : undefined,
|
|
7187
|
+
args: (0, exports.getCloudRunJobArgsArg)(config.args),
|
|
7188
|
+
});
|
|
7189
|
+
const fullJobName = (0, jobName_1.getFullJobName)(context, jobName);
|
|
7190
|
+
return `${(0, common_1.gcloudRunCmd)()} jobs execute ${fullJobName.toString()} ${argString}`;
|
|
7191
|
+
};
|
|
7192
|
+
const getCloudRunJobArgsArg = (args) => {
|
|
7193
|
+
return args !== undefined
|
|
7194
|
+
? args.length > 0
|
|
7195
|
+
? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
|
|
7196
|
+
: ""
|
|
7197
|
+
: undefined;
|
|
7198
|
+
};
|
|
7199
|
+
exports.getCloudRunJobArgsArg = getCloudRunJobArgsArg;
|
|
7200
|
+
//# sourceMappingURL=onDeploy.js.map
|
|
7201
|
+
|
|
7202
|
+
/***/ }),
|
|
7203
|
+
|
|
7204
|
+
/***/ 3697:
|
|
7205
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7206
|
+
|
|
7207
|
+
"use strict";
|
|
7208
|
+
|
|
7209
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7210
|
+
exports.getCreateScheduleScript = exports.getDeleteSchedulesScript = void 0;
|
|
7211
|
+
const bash_1 = __nccwpck_require__(22990);
|
|
7212
|
+
const utils_1 = __nccwpck_require__(32497);
|
|
7213
|
+
const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
|
|
7214
|
+
const createArgsString_1 = __nccwpck_require__(49598);
|
|
7215
|
+
const jobName_1 = __nccwpck_require__(9626);
|
|
7216
|
+
const cloudRunJobs_1 = __nccwpck_require__(61224);
|
|
7217
|
+
const common_1 = __nccwpck_require__(73325);
|
|
7218
|
+
const getDeleteSchedulesScript = (context) => {
|
|
7219
|
+
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
7220
|
+
const schedules = getSchedules(context);
|
|
7221
|
+
const argsString = (0, createArgsString_1.createArgsString)({
|
|
7222
|
+
project: deployConfig.projectId,
|
|
7223
|
+
location: deployConfig.region,
|
|
7224
|
+
});
|
|
7225
|
+
return schedules
|
|
7226
|
+
.map(({ fullName }) => {
|
|
7227
|
+
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${fullName} ${argsString}`];
|
|
7228
|
+
})
|
|
7229
|
+
.flat();
|
|
7230
|
+
};
|
|
7231
|
+
exports.getDeleteSchedulesScript = getDeleteSchedulesScript;
|
|
7232
|
+
const getCreateScheduleScript = (context) => {
|
|
7233
|
+
const schedules = getSchedules(context);
|
|
7234
|
+
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
7235
|
+
return schedules.map(({ fullName, config }, jobIndex) => {
|
|
7236
|
+
var _a;
|
|
7237
|
+
const { uri, ...args } = getSchedulerArgs(config, context);
|
|
7238
|
+
const argsString = (0, createArgsString_1.createArgsString)({
|
|
7239
|
+
project,
|
|
7240
|
+
location,
|
|
7241
|
+
uri: `"$current_job_uri"`,
|
|
7242
|
+
...args,
|
|
7243
|
+
schedule: `"${config.schedule}"`,
|
|
7244
|
+
"max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
7245
|
+
});
|
|
7246
|
+
return [
|
|
7247
|
+
jobIndex === 0
|
|
7248
|
+
? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
|
|
7249
|
+
: null,
|
|
7250
|
+
`current_job_uri="${uri}"`,
|
|
7251
|
+
`current_scheduler_name="${fullName}"`,
|
|
7252
|
+
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
7253
|
+
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
7254
|
+
`else`,
|
|
7255
|
+
` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
|
|
7256
|
+
`fi`,
|
|
7257
|
+
]
|
|
7258
|
+
.filter(utils_1.notNil)
|
|
7259
|
+
.join("\n");
|
|
7260
|
+
});
|
|
7261
|
+
};
|
|
7262
|
+
exports.getCreateScheduleScript = getCreateScheduleScript;
|
|
7263
|
+
const getSchedulerArgs = (scheduler, context) => {
|
|
7264
|
+
var _a;
|
|
7265
|
+
if (scheduler.type === "job") {
|
|
7266
|
+
const { projectId, region } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
7267
|
+
const body = scheduler.args !== undefined
|
|
7268
|
+
? {
|
|
7269
|
+
overrides: {
|
|
7270
|
+
containerOverrides: [
|
|
7271
|
+
((_a = scheduler.args) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
7272
|
+
? {
|
|
7273
|
+
args: scheduler.args,
|
|
7274
|
+
}
|
|
7275
|
+
: {
|
|
7276
|
+
args: [],
|
|
7277
|
+
clearArgs: true, // not sure why this is neeeded, but it is
|
|
7278
|
+
},
|
|
7279
|
+
],
|
|
7280
|
+
},
|
|
7281
|
+
}
|
|
7282
|
+
: null;
|
|
7283
|
+
return {
|
|
7284
|
+
uri: (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(scheduler.job, {
|
|
7285
|
+
appFullName: context.environment.fullName,
|
|
7286
|
+
projectId,
|
|
7287
|
+
region,
|
|
7288
|
+
}),
|
|
7289
|
+
"message-body": body
|
|
7290
|
+
? '"' + (0, bash_1.bashEscape)(JSON.stringify(body)) + '"'
|
|
7291
|
+
: undefined,
|
|
7292
|
+
"http-method": "POST",
|
|
7293
|
+
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
7294
|
+
};
|
|
7295
|
+
}
|
|
7296
|
+
if (scheduler.type === "http") {
|
|
7297
|
+
return {
|
|
7298
|
+
uri: scheduler.url,
|
|
7299
|
+
"message-body": scheduler.body,
|
|
7300
|
+
"http-method": scheduler.method,
|
|
7301
|
+
"oidc-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
7302
|
+
};
|
|
7303
|
+
}
|
|
7304
|
+
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
7305
|
+
};
|
|
7306
|
+
const getSchedules = (context) => {
|
|
7307
|
+
const legacyScheduleJobs = getLegacyJobSchedules(context);
|
|
7308
|
+
const schedules = getScheduledExecutes(context);
|
|
7309
|
+
return Object.entries({ ...legacyScheduleJobs, ...schedules }).map(([name, config]) => ({
|
|
7310
|
+
name,
|
|
7311
|
+
fullName: (0, jobName_1.getFullSchedulerName)(context, name),
|
|
7312
|
+
config,
|
|
7313
|
+
}));
|
|
7314
|
+
};
|
|
7315
|
+
const getLegacyJobSchedules = (context) => {
|
|
7316
|
+
const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
|
|
7317
|
+
return Object.fromEntries(jobsWithNames
|
|
7318
|
+
.filter((entry) => entry.job.when === "schedule")
|
|
7319
|
+
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
7320
|
+
const schedulerName = jobName.concat("-scheduler");
|
|
7321
|
+
return [
|
|
7322
|
+
schedulerName,
|
|
7323
|
+
{
|
|
7324
|
+
type: "job",
|
|
7325
|
+
job: jobName,
|
|
7326
|
+
maxRetryAttempts,
|
|
7327
|
+
schedule,
|
|
7328
|
+
when: "schedule",
|
|
7329
|
+
},
|
|
7330
|
+
];
|
|
7331
|
+
}));
|
|
7332
|
+
};
|
|
7333
|
+
const getScheduledExecutes = (context) => {
|
|
7334
|
+
var _a;
|
|
7335
|
+
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
7336
|
+
return Object.fromEntries(Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
|
|
7337
|
+
if (!value || value.when !== "schedule") {
|
|
7338
|
+
return [];
|
|
7339
|
+
}
|
|
7340
|
+
return [[key, value]];
|
|
7341
|
+
}));
|
|
7342
|
+
};
|
|
7343
|
+
//# sourceMappingURL=schedules.js.map
|
|
7344
|
+
|
|
7345
|
+
/***/ }),
|
|
7346
|
+
|
|
7098
7347
|
/***/ 53695:
|
|
7099
7348
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7100
7349
|
|
|
@@ -7111,9 +7360,11 @@ const cleanup_1 = __nccwpck_require__(67888);
|
|
|
7111
7360
|
const database_1 = __nccwpck_require__(28206);
|
|
7112
7361
|
const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
|
|
7113
7362
|
const cloudRunJobs_1 = __nccwpck_require__(61224);
|
|
7363
|
+
const onDeploy_1 = __nccwpck_require__(2358);
|
|
7114
7364
|
const cloudRunServices_1 = __nccwpck_require__(17334);
|
|
7115
7365
|
const common_1 = __nccwpck_require__(73325);
|
|
7116
7366
|
const constants_1 = __nccwpck_require__(38865);
|
|
7367
|
+
const schedules_1 = __nccwpck_require__(3697);
|
|
7117
7368
|
function getCloudRunDeployScripts(context) {
|
|
7118
7369
|
var _a;
|
|
7119
7370
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
@@ -7128,14 +7379,14 @@ function getCloudRunDeployScripts(context) {
|
|
|
7128
7379
|
...(deployConfig.cloudSql
|
|
7129
7380
|
? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
7130
7381
|
: []),
|
|
7131
|
-
...(0,
|
|
7382
|
+
...(0, schedules_1.getCreateScheduleScript)(context),
|
|
7132
7383
|
...(0, cloudRunJobs_1.getJobCreateScripts)(context),
|
|
7133
|
-
...(0,
|
|
7384
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preDeploy"),
|
|
7134
7385
|
...(deployConfig.service !== false
|
|
7135
7386
|
? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)]
|
|
7136
7387
|
: []),
|
|
7137
7388
|
...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).map(([name, service]) => (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name)),
|
|
7138
|
-
...(0,
|
|
7389
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy"),
|
|
7139
7390
|
]),
|
|
7140
7391
|
...(0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy")),
|
|
7141
7392
|
...(0, sbom_1.getDependencyTrackUploadScript)(context),
|
|
@@ -7158,6 +7409,8 @@ const cleanup_1 = __nccwpck_require__(67888);
|
|
|
7158
7409
|
const database_1 = __nccwpck_require__(28206);
|
|
7159
7410
|
const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
|
|
7160
7411
|
const cloudRunJobs_1 = __nccwpck_require__(61224);
|
|
7412
|
+
const onDeploy_1 = __nccwpck_require__(2358);
|
|
7413
|
+
const schedules_1 = __nccwpck_require__(3697);
|
|
7161
7414
|
const cloudRunServices_1 = __nccwpck_require__(17334);
|
|
7162
7415
|
const common_1 = __nccwpck_require__(73325);
|
|
7163
7416
|
function getCloudRunStopScripts(context) {
|
|
@@ -7165,11 +7418,11 @@ function getCloudRunStopScripts(context) {
|
|
|
7165
7418
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
7166
7419
|
return [
|
|
7167
7420
|
...(0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context),
|
|
7168
|
-
...(0,
|
|
7421
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop"),
|
|
7169
7422
|
...(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []),
|
|
7170
7423
|
...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).flatMap(([name]) => (0, cloudRunServices_1.getServiceDeleteScript)(context, name)),
|
|
7171
|
-
...(0,
|
|
7172
|
-
...(0,
|
|
7424
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop"),
|
|
7425
|
+
...(0, schedules_1.getDeleteSchedulesScript)(context),
|
|
7173
7426
|
...(0, cloudRunJobs_1.getDeleteJobsScripts)(context),
|
|
7174
7427
|
...(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop
|
|
7175
7428
|
? (0, database_1.getDatabaseDeleteScript)(context, deployConfig)
|
|
@@ -7274,8 +7527,8 @@ const context_1 = __nccwpck_require__(5875);
|
|
|
7274
7527
|
const gitlab_1 = __nccwpck_require__(38490);
|
|
7275
7528
|
const utils_1 = __nccwpck_require__(62089);
|
|
7276
7529
|
const createJobs_1 = __nccwpck_require__(34069);
|
|
7530
|
+
const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
|
|
7277
7531
|
const database_1 = __nccwpck_require__(28206);
|
|
7278
|
-
const jobName_1 = __nccwpck_require__(9626);
|
|
7279
7532
|
exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
7280
7533
|
// FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
|
|
7281
7534
|
exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
|
|
@@ -7331,7 +7584,11 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
|
7331
7584
|
const jobTriggers = deployConfigRaw && deployConfigRaw.jobs
|
|
7332
7585
|
? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
|
|
7333
7586
|
"CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name),
|
|
7334
|
-
|
|
7587
|
+
(0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(name, {
|
|
7588
|
+
appFullName: fullName,
|
|
7589
|
+
projectId: deployConfigRaw.projectId,
|
|
7590
|
+
region: deployConfigRaw.region,
|
|
7591
|
+
}),
|
|
7335
7592
|
]))
|
|
7336
7593
|
: {};
|
|
7337
7594
|
return {
|
|
@@ -7351,6 +7608,24 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
|
7351
7608
|
|
|
7352
7609
|
/***/ }),
|
|
7353
7610
|
|
|
7611
|
+
/***/ 24856:
|
|
7612
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7613
|
+
|
|
7614
|
+
"use strict";
|
|
7615
|
+
|
|
7616
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7617
|
+
exports.getCloudRunJobExecuteUrl = void 0;
|
|
7618
|
+
const jobName_1 = __nccwpck_require__(9626);
|
|
7619
|
+
function getCloudRunJobExecuteUrl(jobName, { region, projectId, appFullName, }) {
|
|
7620
|
+
const uriBase = `https://${region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${projectId}/jobs`;
|
|
7621
|
+
const fullJobName = (0, jobName_1.getCloudRunJobName)(appFullName, jobName);
|
|
7622
|
+
return `${uriBase}/${fullJobName}:run`;
|
|
7623
|
+
}
|
|
7624
|
+
exports.getCloudRunJobExecuteUrl = getCloudRunJobExecuteUrl;
|
|
7625
|
+
//# sourceMappingURL=cloudRunExecutionUrl.js.map
|
|
7626
|
+
|
|
7627
|
+
/***/ }),
|
|
7628
|
+
|
|
7354
7629
|
/***/ 49598:
|
|
7355
7630
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7356
7631
|
|
|
@@ -7485,9 +7760,15 @@ exports.getServiceName = getServiceName;
|
|
|
7485
7760
|
"use strict";
|
|
7486
7761
|
|
|
7487
7762
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7488
|
-
exports.getCloudRunJobName = void 0;
|
|
7763
|
+
exports.getFullSchedulerName = exports.getCloudRunSchedulerName = exports.getFullJobName = exports.getCloudRunJobName = void 0;
|
|
7489
7764
|
const getCloudRunJobName = (fullAppName, jobName) => fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
|
|
7490
7765
|
exports.getCloudRunJobName = getCloudRunJobName;
|
|
7766
|
+
const getFullJobName = (context, name) => (0, exports.getCloudRunJobName)(context.environment.fullName, name);
|
|
7767
|
+
exports.getFullJobName = getFullJobName;
|
|
7768
|
+
const getCloudRunSchedulerName = (fullAppName, schedulerName) => fullAppName.toLowerCase().concat("-" + schedulerName.toLowerCase());
|
|
7769
|
+
exports.getCloudRunSchedulerName = getCloudRunSchedulerName;
|
|
7770
|
+
const getFullSchedulerName = (context, name) => (0, exports.getCloudRunSchedulerName)(context.environment.fullName, name);
|
|
7771
|
+
exports.getFullSchedulerName = getFullSchedulerName;
|
|
7491
7772
|
//# sourceMappingURL=jobName.js.map
|
|
7492
7773
|
|
|
7493
7774
|
/***/ }),
|
|
@@ -8258,7 +8539,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
8258
8539
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
8259
8540
|
};
|
|
8260
8541
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8261
|
-
exports.isOfDeployType = void 0;
|
|
8542
|
+
exports.getDeployConfigType = exports.isOfDeployType = void 0;
|
|
8262
8543
|
__exportStar(__nccwpck_require__(30461), exports);
|
|
8263
8544
|
__exportStar(__nccwpck_require__(66938), exports);
|
|
8264
8545
|
__exportStar(__nccwpck_require__(60835), exports);
|
|
@@ -8267,6 +8548,12 @@ const isOfDeployType = (t, ...types) => {
|
|
|
8267
8548
|
return t && types.includes(t.type) ? true : false;
|
|
8268
8549
|
};
|
|
8269
8550
|
exports.isOfDeployType = isOfDeployType;
|
|
8551
|
+
const getDeployConfigType = (t) => {
|
|
8552
|
+
if (!t)
|
|
8553
|
+
return undefined;
|
|
8554
|
+
return t.type;
|
|
8555
|
+
};
|
|
8556
|
+
exports.getDeployConfigType = getDeployConfigType;
|
|
8270
8557
|
//# sourceMappingURL=index.js.map
|
|
8271
8558
|
|
|
8272
8559
|
/***/ }),
|