@catladder/cli 0.0.0-main-7b4a3dd5 → 0.0.0-main-5bc1bdb9
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/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/apps/cli/commands/project/index.js +2 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +2 -2
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/bundles/catenv/index.js +279 -108
- package/dist/bundles/cli/index.js +380 -110
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/gitlab.d.ts +3 -1
- package/dist/utils/gitlab.js +60 -9
- package/dist/utils/gitlab.js.map +1 -1
- package/package.json +2 -2
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
- package/src/apps/cli/commands/project/index.ts +2 -0
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +21 -10
- package/src/utils/gitlab.ts +50 -12
|
@@ -613,7 +613,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
613
613
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
614
614
|
};
|
|
615
615
|
exports.__esModule = true;
|
|
616
|
-
exports.upsertAllVariables = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
|
|
616
|
+
exports.upsertAllVariables = exports.clearBackups = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
|
|
617
617
|
var pipeline_1 = __nccwpck_require__(5355);
|
|
618
618
|
var child_process_promise_1 = __nccwpck_require__(5763);
|
|
619
619
|
var lodash_1 = __nccwpck_require__(3255);
|
|
@@ -687,28 +687,31 @@ var getGitlabToken = function (vorpal) { return __awaiter(void 0, void 0, void 0
|
|
|
687
687
|
});
|
|
688
688
|
}); };
|
|
689
689
|
exports.getGitlabToken = getGitlabToken;
|
|
690
|
-
var doGitlabRequest = function (vorpal, path, data,
|
|
690
|
+
var doGitlabRequest = function (vorpal, path, data, method) {
|
|
691
691
|
if (data === void 0) { data = undefined; }
|
|
692
|
+
if (method === void 0) { method = "GET"; }
|
|
692
693
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
693
|
-
var rootToken,
|
|
694
|
+
var rootToken, result, _a, _b, _c, _d, _e;
|
|
694
695
|
return __generator(this, function (_f) {
|
|
695
696
|
switch (_f.label) {
|
|
696
697
|
case 0: return [4 /*yield*/, (0, exports.getGitlabToken)(vorpal)];
|
|
697
698
|
case 1:
|
|
698
699
|
rootToken = _f.sent();
|
|
699
|
-
method = data ? (update ? "PUT" : "POST") : "GET";
|
|
700
700
|
return [4 /*yield*/, (0, node_fetch_1["default"])("https://git.panter.ch/api/v4/".concat(path), {
|
|
701
701
|
method: method,
|
|
702
702
|
headers: {
|
|
703
703
|
"Content-Type": "application/json",
|
|
704
704
|
"Private-Token": rootToken
|
|
705
705
|
},
|
|
706
|
-
body: JSON.stringify(data)
|
|
706
|
+
body: data ? JSON.stringify(data) : undefined
|
|
707
707
|
})];
|
|
708
708
|
case 2:
|
|
709
709
|
result = _f.sent();
|
|
710
710
|
if (result.status >= 200 && result.status < 400) {
|
|
711
|
-
|
|
711
|
+
if (result.headers.get("content-type") === "application/json") {
|
|
712
|
+
return [2 /*return*/, result.json()];
|
|
713
|
+
}
|
|
714
|
+
return [2 /*return*/, null];
|
|
712
715
|
}
|
|
713
716
|
if (result.status === 404) {
|
|
714
717
|
throw new Error("not found");
|
|
@@ -790,7 +793,7 @@ var createVariable = function (vorpal, projectId, key, value, masked, environmen
|
|
|
790
793
|
value: value,
|
|
791
794
|
masked: masked && isMaskable(value),
|
|
792
795
|
environment_scope: environment_scope
|
|
793
|
-
})];
|
|
796
|
+
}, "POST")];
|
|
794
797
|
case 1: return [2 /*return*/, _a.sent()];
|
|
795
798
|
}
|
|
796
799
|
});
|
|
@@ -804,12 +807,20 @@ var updateVariable = function (vorpal, projectId, key, value, masked) {
|
|
|
804
807
|
case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables/").concat(key), {
|
|
805
808
|
value: value,
|
|
806
809
|
masked: masked && isMaskable(value)
|
|
807
|
-
},
|
|
810
|
+
}, "PUT")];
|
|
808
811
|
case 1: return [2 /*return*/, _a.sent()];
|
|
809
812
|
}
|
|
810
813
|
});
|
|
811
814
|
});
|
|
812
815
|
};
|
|
816
|
+
var deleteVariable = function (vorpal, projectId, key) { return __awaiter(void 0, void 0, void 0, function () {
|
|
817
|
+
return __generator(this, function (_a) {
|
|
818
|
+
switch (_a.label) {
|
|
819
|
+
case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables/").concat(key), undefined, "DELETE")];
|
|
820
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
}); };
|
|
813
824
|
var getAllCatladderEnvVarsInGitlab = function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
814
825
|
var allVariables;
|
|
815
826
|
return __generator(this, function (_a) {
|
|
@@ -839,6 +850,46 @@ var getAllCatladderEnvVarsInGitlab = function (vorpal) { return __awaiter(void 0
|
|
|
839
850
|
}
|
|
840
851
|
});
|
|
841
852
|
}); };
|
|
853
|
+
var getBackupKey = function (fullKey, timestamp) {
|
|
854
|
+
return "".concat(fullKey, "_backup_").concat(timestamp);
|
|
855
|
+
};
|
|
856
|
+
var clearBackups = function (vorpal, keep) { return __awaiter(void 0, void 0, void 0, function () {
|
|
857
|
+
var existingVariables, id, _i, _a, _b, key, backups, backupsSorted, toDelete, _c, toDelete_1, timestamp;
|
|
858
|
+
return __generator(this, function (_d) {
|
|
859
|
+
switch (_d.label) {
|
|
860
|
+
case 0: return [4 /*yield*/, getAllCatladderEnvVarsInGitlab(vorpal)];
|
|
861
|
+
case 1:
|
|
862
|
+
existingVariables = _d.sent();
|
|
863
|
+
return [4 /*yield*/, (0, exports.getProjectInfo)(vorpal)];
|
|
864
|
+
case 2:
|
|
865
|
+
id = (_d.sent()).id;
|
|
866
|
+
_i = 0, _a = Object.entries(existingVariables);
|
|
867
|
+
_d.label = 3;
|
|
868
|
+
case 3:
|
|
869
|
+
if (!(_i < _a.length)) return [3 /*break*/, 8];
|
|
870
|
+
_b = _a[_i], key = _b[0], backups = _b[1].backups;
|
|
871
|
+
backupsSorted = backups.sort(function (a, b) { return b - a; });
|
|
872
|
+
toDelete = backupsSorted.slice(keep);
|
|
873
|
+
_c = 0, toDelete_1 = toDelete;
|
|
874
|
+
_d.label = 4;
|
|
875
|
+
case 4:
|
|
876
|
+
if (!(_c < toDelete_1.length)) return [3 /*break*/, 7];
|
|
877
|
+
timestamp = toDelete_1[_c];
|
|
878
|
+
return [4 /*yield*/, deleteVariable(vorpal, id, getBackupKey(key, timestamp))];
|
|
879
|
+
case 5:
|
|
880
|
+
_d.sent();
|
|
881
|
+
_d.label = 6;
|
|
882
|
+
case 6:
|
|
883
|
+
_c++;
|
|
884
|
+
return [3 /*break*/, 4];
|
|
885
|
+
case 7:
|
|
886
|
+
_i++;
|
|
887
|
+
return [3 /*break*/, 3];
|
|
888
|
+
case 8: return [2 /*return*/];
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
}); };
|
|
892
|
+
exports.clearBackups = clearBackups;
|
|
842
893
|
var upsertAllVariables = function (vorpal, variables, env, componentName, backup, masked // FIXME: would be better to have this per variable
|
|
843
894
|
) {
|
|
844
895
|
if (backup === void 0) { backup = true; }
|
|
@@ -871,7 +922,7 @@ var upsertAllVariables = function (vorpal, variables, env, componentName, backup
|
|
|
871
922
|
case 4:
|
|
872
923
|
_d.sent();
|
|
873
924
|
if (!backup) return [3 /*break*/, 6];
|
|
874
|
-
return [4 /*yield*/, createVariable(vorpal, id, fullKey
|
|
925
|
+
return [4 /*yield*/, createVariable(vorpal, id, getBackupKey(fullKey, new Date().getTime()), oldValue, masked, "_backup")];
|
|
875
926
|
case 5:
|
|
876
927
|
_d.sent();
|
|
877
928
|
_d.label = 6;
|
|
@@ -39831,7 +39882,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
39831
39882
|
|
|
39832
39883
|
exports.__esModule = true;
|
|
39833
39884
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
39834
|
-
exports.PIPELINE_IMAGE_TAG = "main-
|
|
39885
|
+
exports.PIPELINE_IMAGE_TAG = "main-5bc1bdb9" || 0;
|
|
39835
39886
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
39836
39887
|
|
|
39837
39888
|
/***/ }),
|
|
@@ -40032,52 +40083,19 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
40032
40083
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40033
40084
|
};
|
|
40034
40085
|
|
|
40035
|
-
var __importDefault = this && this.__importDefault || function (mod) {
|
|
40036
|
-
return mod && mod.__esModule ? mod : {
|
|
40037
|
-
"default": mod
|
|
40038
|
-
};
|
|
40039
|
-
};
|
|
40040
|
-
|
|
40041
40086
|
exports.__esModule = true;
|
|
40042
|
-
exports.
|
|
40087
|
+
exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironment = void 0;
|
|
40043
40088
|
|
|
40044
40089
|
var lodash_1 = __nccwpck_require__(3255);
|
|
40045
40090
|
|
|
40046
|
-
var slugify_1 = __importDefault(__nccwpck_require__(4035));
|
|
40047
|
-
|
|
40048
40091
|
var deploy_1 = __nccwpck_require__(223);
|
|
40049
40092
|
|
|
40050
|
-
var types_1 = __nccwpck_require__(3109);
|
|
40051
|
-
|
|
40052
40093
|
var config_1 = __nccwpck_require__(9997);
|
|
40053
40094
|
|
|
40054
40095
|
var utils_1 = __nccwpck_require__(7461);
|
|
40055
40096
|
|
|
40056
40097
|
var resolveReferences_1 = __nccwpck_require__(928);
|
|
40057
40098
|
|
|
40058
|
-
var sanitizeForEnVar = function (s) {
|
|
40059
|
-
return s.replace(/-/g, "_");
|
|
40060
|
-
};
|
|
40061
|
-
|
|
40062
|
-
var getSecretVarName = function (env, componentName, key) {
|
|
40063
|
-
return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
|
|
40064
|
-
}; // remove dash from component name
|
|
40065
|
-
|
|
40066
|
-
|
|
40067
|
-
exports.getSecretVarName = getSecretVarName;
|
|
40068
|
-
|
|
40069
|
-
var addIndexVar = function (vars) {
|
|
40070
|
-
return __assign(__assign({}, vars), {
|
|
40071
|
-
_ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
|
|
40072
|
-
});
|
|
40073
|
-
};
|
|
40074
|
-
|
|
40075
|
-
var getSecretVarNameForContext = function (context, key) {
|
|
40076
|
-
return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
|
|
40077
|
-
};
|
|
40078
|
-
|
|
40079
|
-
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
|
40080
|
-
|
|
40081
40099
|
var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
|
|
40082
40100
|
) {
|
|
40083
40101
|
if (alreadyVisited === void 0) {
|
|
@@ -40085,27 +40103,15 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
|
|
|
40085
40103
|
}
|
|
40086
40104
|
|
|
40087
40105
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
40088
|
-
var
|
|
40106
|
+
var envConfig, envType, basePredefinedVariables, gitlabEnvironmentName, environmentSlug, predefinedVariables, host, url, fullName, envVarContext, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
|
|
40089
40107
|
|
|
40090
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
40108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
40091
40109
|
|
|
40092
|
-
return __generator(this, function (
|
|
40093
|
-
switch (
|
|
40110
|
+
return __generator(this, function (_l) {
|
|
40111
|
+
switch (_l.label) {
|
|
40094
40112
|
case 0:
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
if (!defaultConfig) {
|
|
40098
|
-
throw new Error("unknown component " + componentName);
|
|
40099
|
-
}
|
|
40100
|
-
|
|
40101
|
-
envConfig = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
|
|
40102
|
-
|
|
40103
|
-
if (envConfig === false) {
|
|
40104
|
-
throw new Error("env is disabled: " + env);
|
|
40105
|
-
}
|
|
40106
|
-
|
|
40107
|
-
mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig);
|
|
40108
|
-
envType = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _c !== void 0 ? _c : (0, config_1.isKnowEnvType)(env) ? env : null;
|
|
40113
|
+
envConfig = getEnvConfig(config, componentName, env);
|
|
40114
|
+
envType = (_a = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _a !== void 0 ? _a : (0, config_1.isKnowEnvType)(env) ? env : null;
|
|
40109
40115
|
|
|
40110
40116
|
if (!envType) {
|
|
40111
40117
|
throw new Error("Missing type in environment " + env + " in component " + componentName);
|
|
@@ -40113,16 +40119,25 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
|
|
|
40113
40119
|
|
|
40114
40120
|
basePredefinedVariables = {
|
|
40115
40121
|
ENV_SHORT: env,
|
|
40116
|
-
APP_DIR:
|
|
40122
|
+
APP_DIR: envConfig.dir,
|
|
40117
40123
|
ENV_TYPE: envType
|
|
40118
40124
|
};
|
|
40119
40125
|
gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
|
|
40120
40126
|
environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
|
|
40121
40127
|
fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
|
|
40128
|
+
envVarContext = {
|
|
40129
|
+
deployConfig: envConfig.deploy,
|
|
40130
|
+
fullName: fullName,
|
|
40131
|
+
envType: envType,
|
|
40132
|
+
commitInfo: commitInfo,
|
|
40133
|
+
componentName: componentName,
|
|
40134
|
+
env: env,
|
|
40135
|
+
fullConfig: config
|
|
40136
|
+
};
|
|
40122
40137
|
|
|
40123
40138
|
if (envType === "local") {
|
|
40124
|
-
devLocalConfig =
|
|
40125
|
-
port = (
|
|
40139
|
+
devLocalConfig = envConfig;
|
|
40140
|
+
port = (_b = devLocalConfig.port) !== null && _b !== void 0 ? _b : 3000;
|
|
40126
40141
|
host = "localhost:" + port;
|
|
40127
40142
|
url = "http://" + host;
|
|
40128
40143
|
predefinedVariables = {
|
|
@@ -40131,34 +40146,22 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
|
|
|
40131
40146
|
PORT: port.toString()
|
|
40132
40147
|
};
|
|
40133
40148
|
} else {
|
|
40134
|
-
|
|
40135
|
-
|
|
40136
|
-
domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy.type) === "kubernetes" && ((_e = mergedConfig.deploy.cluster) === null || _e === void 0 ? void 0 : _e.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
|
|
40137
|
-
config.domainCanonical || "panter.cloud";
|
|
40138
|
-
HOST_CANONICAL = (0, types_1.isOfDeployType)(mergedConfig.deploy, "google-cloudrun") ? fullName.toLowerCase() + "-" + process.env[(0, exports.getSecretVarName)(env, componentName, deploy_1.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)] : "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical);
|
|
40139
|
-
host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
|
|
40149
|
+
additionalEnvVars = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].getAdditionalEnvVars(envVarContext) : {};
|
|
40150
|
+
host = (_d = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.host) !== null && _c !== void 0 ? _c : additionalEnvVars.HOST_CANONICAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
|
|
40140
40151
|
url = "https://".concat(host);
|
|
40141
|
-
|
|
40142
|
-
KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
|
|
40143
|
-
KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
|
|
40144
|
-
predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
|
|
40145
|
-
HOST_CANONICAL: HOST_CANONICAL,
|
|
40152
|
+
predefinedVariables = __assign(__assign(__assign({}, basePredefinedVariables), {
|
|
40146
40153
|
HOST: host,
|
|
40147
|
-
ROOT_URL: url
|
|
40148
|
-
|
|
40149
|
-
KUBE_APP_NAME: KUBE_APP_NAME,
|
|
40150
|
-
KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX
|
|
40151
|
-
});
|
|
40154
|
+
ROOT_URL: url
|
|
40155
|
+
}), additionalEnvVars);
|
|
40152
40156
|
}
|
|
40153
40157
|
|
|
40154
|
-
publicEnvVarsRaw = (
|
|
40155
|
-
additionalSecretKeys =
|
|
40156
|
-
|
|
40157
|
-
secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_k = (_j = mergedConfig.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : []), false), __read(additionalSecretKeys), false);
|
|
40158
|
+
publicEnvVarsRaw = (_f = (_e = envConfig.vars) === null || _e === void 0 ? void 0 : _e.public) !== null && _f !== void 0 ? _f : {};
|
|
40159
|
+
additionalSecretKeys = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].additionalSecretKeys(envVarContext) : [];
|
|
40160
|
+
secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_h = (_g = envConfig.vars) === null || _g === void 0 ? void 0 : _g.secret) !== null && _h !== void 0 ? _h : []), false), __read(additionalSecretKeys), false);
|
|
40158
40161
|
secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
|
|
40159
40162
|
return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
|
|
40160
40163
|
}));
|
|
40161
|
-
legacyFromComponents = (
|
|
40164
|
+
legacyFromComponents = (_k = (_j = envConfig.vars) === null || _j === void 0 ? void 0 : _j.fromComponents) !== null && _k !== void 0 ? _k : {};
|
|
40162
40165
|
publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
|
|
40163
40166
|
publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
|
|
40164
40167
|
var _b = __read(_a, 2),
|
|
@@ -40191,7 +40194,7 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
|
|
|
40191
40194
|
}, alreadyVisited)];
|
|
40192
40195
|
|
|
40193
40196
|
case 1:
|
|
40194
|
-
envVars =
|
|
40197
|
+
envVars = _l.sent();
|
|
40195
40198
|
return [2
|
|
40196
40199
|
/*return*/
|
|
40197
40200
|
, {
|
|
@@ -40215,6 +40218,47 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
|
|
|
40215
40218
|
|
|
40216
40219
|
exports.getEnvironment = getEnvironment;
|
|
40217
40220
|
|
|
40221
|
+
var sanitizeForEnVar = function (s) {
|
|
40222
|
+
return s.replace(/-/g, "_");
|
|
40223
|
+
};
|
|
40224
|
+
|
|
40225
|
+
var getSecretVarName = function (env, componentName, key) {
|
|
40226
|
+
return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
|
|
40227
|
+
}; // remove dash from component name
|
|
40228
|
+
|
|
40229
|
+
|
|
40230
|
+
exports.getSecretVarName = getSecretVarName;
|
|
40231
|
+
|
|
40232
|
+
var addIndexVar = function (vars) {
|
|
40233
|
+
return __assign(__assign({}, vars), {
|
|
40234
|
+
_ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
|
|
40235
|
+
});
|
|
40236
|
+
};
|
|
40237
|
+
|
|
40238
|
+
var getSecretVarNameForContext = function (context, key) {
|
|
40239
|
+
return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
|
|
40240
|
+
};
|
|
40241
|
+
|
|
40242
|
+
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
|
40243
|
+
|
|
40244
|
+
var getEnvConfig = function (config, componentName, env) {
|
|
40245
|
+
var _a, _b;
|
|
40246
|
+
|
|
40247
|
+
var defaultConfig = config.components[componentName];
|
|
40248
|
+
|
|
40249
|
+
if (!defaultConfig) {
|
|
40250
|
+
throw new Error("unknown component " + componentName);
|
|
40251
|
+
}
|
|
40252
|
+
|
|
40253
|
+
var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
|
|
40254
|
+
|
|
40255
|
+
if (envCustomizations === false) {
|
|
40256
|
+
throw new Error("env is disabled: " + env);
|
|
40257
|
+
}
|
|
40258
|
+
|
|
40259
|
+
return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
|
|
40260
|
+
};
|
|
40261
|
+
|
|
40218
40262
|
/***/ }),
|
|
40219
40263
|
|
|
40220
40264
|
/***/ 486:
|
|
@@ -41043,7 +41087,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
41043
41087
|
};
|
|
41044
41088
|
|
|
41045
41089
|
exports.__esModule = true;
|
|
41046
|
-
exports.
|
|
41090
|
+
exports.createGoogleCloudRunDeployJobs = void 0;
|
|
41047
41091
|
|
|
41048
41092
|
var js_yaml_1 = __nccwpck_require__(3618);
|
|
41049
41093
|
|
|
@@ -41063,16 +41107,16 @@ var types_1 = __nccwpck_require__(3109);
|
|
|
41063
41107
|
|
|
41064
41108
|
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
|
|
41065
41109
|
|
|
41066
|
-
var
|
|
41110
|
+
var createGoogleCloudRunDeployJobs = function (context) {
|
|
41067
41111
|
var deployConfig = context.componentConfig.deploy;
|
|
41068
41112
|
|
|
41069
41113
|
if (deployConfig === false) {
|
|
41070
41114
|
return [];
|
|
41071
41115
|
}
|
|
41072
41116
|
|
|
41073
|
-
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
41117
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun", "google-cloudrun-job")) {
|
|
41074
41118
|
// should not happen
|
|
41075
|
-
throw new Error("deploy config is
|
|
41119
|
+
throw new Error("deploy config is wrong");
|
|
41076
41120
|
}
|
|
41077
41121
|
|
|
41078
41122
|
var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
|
|
@@ -41083,7 +41127,6 @@ var createDeployJob = function (context) {
|
|
|
41083
41127
|
var pushImageToArtifactsRegistry = __spreadArray(__spreadArray([docker_1.gitlabDockerLogin], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat(deployConfig.region, "-docker.pkg.dev"), "docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG ".concat(gcloudImageName), "docker push ".concat(gcloudImageName)], false);
|
|
41084
41128
|
|
|
41085
41129
|
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
41086
|
-
var serviceName = context.environment.fullName.toLowerCase();
|
|
41087
41130
|
var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
|
|
41088
41131
|
var _b = __read(_a, 2),
|
|
41089
41132
|
key = _b[0],
|
|
@@ -41091,9 +41134,39 @@ var createDeployJob = function (context) {
|
|
|
41091
41134
|
|
|
41092
41135
|
return "".concat(key, "=").concat(value);
|
|
41093
41136
|
}).join(",");
|
|
41094
|
-
var
|
|
41137
|
+
var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
|
|
41138
|
+
|
|
41139
|
+
var getDeployCommand = function () {
|
|
41140
|
+
var _a;
|
|
41141
|
+
|
|
41142
|
+
var name = context.environment.fullName.toLowerCase();
|
|
41143
|
+
var command = (_a = deployConfig.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand;
|
|
41144
|
+
var commandArg = command ? "--command=\"".concat(command.split(" ").join(","), "\"") : "";
|
|
41145
|
+
var commonDeployArgs = "".concat(commandArg, " --image ").concat(gcloudImageName, " ").concat(commonArgs, " --env-vars-file=____envvars.yaml --labels ").concat(labelsString);
|
|
41146
|
+
|
|
41147
|
+
if (deployConfig.type === "google-cloudrun") {
|
|
41148
|
+
return "gcloud run deploy ".concat(name, " ").concat(commonDeployArgs, " --allow-unauthenticated");
|
|
41149
|
+
}
|
|
41150
|
+
|
|
41151
|
+
if (deployConfig.type === "google-cloudrun-job") {
|
|
41152
|
+
return "gcloud beta run jobs create ".concat(name, " ").concat(commonDeployArgs);
|
|
41153
|
+
}
|
|
41154
|
+
};
|
|
41155
|
+
|
|
41156
|
+
var getStopCommand = function () {
|
|
41157
|
+
var name = context.environment.fullName.toLowerCase();
|
|
41158
|
+
var commonStopArgs = "".concat(commonArgs, " --quiet");
|
|
41095
41159
|
|
|
41096
|
-
|
|
41160
|
+
if (deployConfig.type === "google-cloudrun") {
|
|
41161
|
+
return "gcloud run services delete ".concat(name, " ").concat(commonStopArgs);
|
|
41162
|
+
}
|
|
41163
|
+
|
|
41164
|
+
if (deployConfig.type === "google-cloudrun-job") {
|
|
41165
|
+
return "gcloud beta run jobs delete ".concat(name, " ").concat(commonStopArgs);
|
|
41166
|
+
}
|
|
41167
|
+
};
|
|
41168
|
+
|
|
41169
|
+
var cloudRunDeploy = ["echo \"$ENV_VARS\" > ____envvars.yaml", getDeployCommand(), "docker image rm ".concat(gcloudImageName)];
|
|
41097
41170
|
var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
|
|
41098
41171
|
return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
|
|
41099
41172
|
artifacts: {
|
|
@@ -41110,11 +41183,11 @@ var createDeployJob = function (context) {
|
|
|
41110
41183
|
script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeploy), false)
|
|
41111
41184
|
}), (0, lodash_1.merge)({}, baseStopJob, {
|
|
41112
41185
|
image: (0, runner_1.getRunnerImage)("gcloud"),
|
|
41113
|
-
script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), [
|
|
41186
|
+
script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), [getStopCommand()], false)
|
|
41114
41187
|
})];
|
|
41115
41188
|
};
|
|
41116
41189
|
|
|
41117
|
-
exports.
|
|
41190
|
+
exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
|
|
41118
41191
|
|
|
41119
41192
|
/***/ }),
|
|
41120
41193
|
|
|
@@ -41125,21 +41198,59 @@ exports.createDeployJob = createDeployJob;
|
|
|
41125
41198
|
|
|
41126
41199
|
|
|
41127
41200
|
exports.__esModule = true;
|
|
41128
|
-
exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
|
|
41201
|
+
exports.GCLOUD_RUN_DEPLOY_TYPES = exports.GCLOUD_RUN_JOB_DEPLOY_TYPE = exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
|
|
41202
|
+
|
|
41203
|
+
var context_1 = __nccwpck_require__(2041);
|
|
41129
41204
|
|
|
41130
41205
|
var deployJob_1 = __nccwpck_require__(2256);
|
|
41131
41206
|
|
|
41132
41207
|
exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
41133
41208
|
exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
|
|
41134
41209
|
exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
41135
|
-
jobs: deployJob_1.
|
|
41210
|
+
jobs: deployJob_1.createGoogleCloudRunDeployJobs,
|
|
41136
41211
|
defaults: function () {
|
|
41137
41212
|
return {};
|
|
41138
41213
|
},
|
|
41139
41214
|
additionalSecretKeys: function () {
|
|
41140
41215
|
return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
|
|
41216
|
+
},
|
|
41217
|
+
getAdditionalEnvVars: function (_a) {
|
|
41218
|
+
var fullName = _a.fullName,
|
|
41219
|
+
env = _a.env,
|
|
41220
|
+
componentName = _a.componentName;
|
|
41221
|
+
var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
|
|
41222
|
+
return {
|
|
41223
|
+
HOST_CANONICAL: HOST_CANONICAL
|
|
41224
|
+
};
|
|
41141
41225
|
}
|
|
41142
41226
|
};
|
|
41227
|
+
exports.GCLOUD_RUN_JOB_DEPLOY_TYPE = {
|
|
41228
|
+
jobs: deployJob_1.createGoogleCloudRunDeployJobs,
|
|
41229
|
+
defaults: function () {
|
|
41230
|
+
return {};
|
|
41231
|
+
},
|
|
41232
|
+
additionalSecretKeys: function () {
|
|
41233
|
+
return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
|
|
41234
|
+
},
|
|
41235
|
+
getAdditionalEnvVars: function (_a) {
|
|
41236
|
+
var deployConfig = _a.deployConfig,
|
|
41237
|
+
fullName = _a.fullName;
|
|
41238
|
+
|
|
41239
|
+
if (!deployConfig) {
|
|
41240
|
+
return {};
|
|
41241
|
+
}
|
|
41242
|
+
|
|
41243
|
+
var jobName = fullName.toLowerCase();
|
|
41244
|
+
var CLOUD_RUN_JOB_TRIGGER_URL = "https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run");
|
|
41245
|
+
return {
|
|
41246
|
+
CLOUD_RUN_JOB_TRIGGER_URL: CLOUD_RUN_JOB_TRIGGER_URL
|
|
41247
|
+
};
|
|
41248
|
+
}
|
|
41249
|
+
};
|
|
41250
|
+
exports.GCLOUD_RUN_DEPLOY_TYPES = {
|
|
41251
|
+
"google-cloudrun": exports.GCLOUD_RUN_DEPLOY_TYPE,
|
|
41252
|
+
"google-cloudrun-job": exports.GCLOUD_RUN_JOB_DEPLOY_TYPE
|
|
41253
|
+
};
|
|
41143
41254
|
|
|
41144
41255
|
/***/ }),
|
|
41145
41256
|
|
|
@@ -41294,6 +41405,9 @@ exports.CUSTOM_DEPLOY_TYPE = {
|
|
|
41294
41405
|
},
|
|
41295
41406
|
additionalSecretKeys: function () {
|
|
41296
41407
|
return [];
|
|
41408
|
+
},
|
|
41409
|
+
getAdditionalEnvVars: function () {
|
|
41410
|
+
return {};
|
|
41297
41411
|
}
|
|
41298
41412
|
};
|
|
41299
41413
|
|
|
@@ -41357,6 +41471,9 @@ exports.DOCKER_TAG_DEPLOY_TYPE = {
|
|
|
41357
41471
|
},
|
|
41358
41472
|
additionalSecretKeys: function () {
|
|
41359
41473
|
return [];
|
|
41474
|
+
},
|
|
41475
|
+
getAdditionalEnvVars: function () {
|
|
41476
|
+
return {};
|
|
41360
41477
|
}
|
|
41361
41478
|
};
|
|
41362
41479
|
|
|
@@ -41368,6 +41485,20 @@ exports.DOCKER_TAG_DEPLOY_TYPE = {
|
|
|
41368
41485
|
"use strict";
|
|
41369
41486
|
|
|
41370
41487
|
|
|
41488
|
+
var __assign = this && this.__assign || function () {
|
|
41489
|
+
__assign = Object.assign || function (t) {
|
|
41490
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
41491
|
+
s = arguments[i];
|
|
41492
|
+
|
|
41493
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41494
|
+
}
|
|
41495
|
+
|
|
41496
|
+
return t;
|
|
41497
|
+
};
|
|
41498
|
+
|
|
41499
|
+
return __assign.apply(this, arguments);
|
|
41500
|
+
};
|
|
41501
|
+
|
|
41371
41502
|
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
41372
41503
|
if (k2 === undefined) k2 = k;
|
|
41373
41504
|
Object.defineProperty(o, k2, {
|
|
@@ -41406,12 +41537,11 @@ __exportStar(__nccwpck_require__(3539), exports);
|
|
|
41406
41537
|
|
|
41407
41538
|
__exportStar(__nccwpck_require__(1344), exports);
|
|
41408
41539
|
|
|
41409
|
-
exports.DEPLOY_TYPES = {
|
|
41540
|
+
exports.DEPLOY_TYPES = __assign({
|
|
41410
41541
|
kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
|
|
41411
41542
|
custom: custom_1.CUSTOM_DEPLOY_TYPE,
|
|
41412
|
-
"google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE,
|
|
41413
41543
|
dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE
|
|
41414
|
-
};
|
|
41544
|
+
}, cloudRun_1.GCLOUD_RUN_DEPLOY_TYPES);
|
|
41415
41545
|
|
|
41416
41546
|
/***/ }),
|
|
41417
41547
|
|
|
@@ -41424,20 +41554,26 @@ exports.DEPLOY_TYPES = {
|
|
|
41424
41554
|
exports.__esModule = true;
|
|
41425
41555
|
exports.additionalKubernetesSecretKeys = void 0;
|
|
41426
41556
|
|
|
41427
|
-
var additionalKubernetesSecretKeys = function (
|
|
41428
|
-
var
|
|
41557
|
+
var additionalKubernetesSecretKeys = function (_a) {
|
|
41558
|
+
var _b, _c, _d, _e;
|
|
41559
|
+
|
|
41560
|
+
var deployConfig = _a.deployConfig;
|
|
41561
|
+
|
|
41562
|
+
if (!deployConfig) {
|
|
41563
|
+
return [];
|
|
41564
|
+
}
|
|
41429
41565
|
|
|
41430
41566
|
var keys = [];
|
|
41431
41567
|
|
|
41432
|
-
if ((
|
|
41568
|
+
if ((_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
41433
41569
|
keys.push("MONGODB_ROOT_PASSWORD");
|
|
41434
41570
|
|
|
41435
|
-
if (
|
|
41571
|
+
if (deployConfig.values.mongodb.architecture === "replicaset") {
|
|
41436
41572
|
keys.push("MONGODB_REPLICASET_KEY");
|
|
41437
41573
|
}
|
|
41438
41574
|
}
|
|
41439
41575
|
|
|
41440
|
-
if ((
|
|
41576
|
+
if ((_e = (_d = deployConfig.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
|
|
41441
41577
|
keys.push("POSTGRESQL_PASSWORD");
|
|
41442
41578
|
keys.push("cloudsqlProxyCredentials");
|
|
41443
41579
|
}
|
|
@@ -41607,14 +41743,24 @@ exports.createKubernetesDeployJobs = createKubernetesDeployJobs;
|
|
|
41607
41743
|
/***/ }),
|
|
41608
41744
|
|
|
41609
41745
|
/***/ 5682:
|
|
41610
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__)
|
|
41746
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
41611
41747
|
|
|
41612
41748
|
"use strict";
|
|
41613
41749
|
|
|
41614
41750
|
|
|
41751
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
41752
|
+
return mod && mod.__esModule ? mod : {
|
|
41753
|
+
"default": mod
|
|
41754
|
+
};
|
|
41755
|
+
};
|
|
41756
|
+
|
|
41615
41757
|
exports.__esModule = true;
|
|
41616
41758
|
exports.KUBERNETES_DEPLOY_TYPE = void 0;
|
|
41617
41759
|
|
|
41760
|
+
var slugify_1 = __importDefault(__nccwpck_require__(4035));
|
|
41761
|
+
|
|
41762
|
+
var __1 = __nccwpck_require__(223);
|
|
41763
|
+
|
|
41618
41764
|
var additionalSecretKeys_1 = __nccwpck_require__(5775);
|
|
41619
41765
|
|
|
41620
41766
|
var deployJob_1 = __nccwpck_require__(9792);
|
|
@@ -41624,7 +41770,32 @@ exports.KUBERNETES_DEPLOY_TYPE = {
|
|
|
41624
41770
|
defaults: function () {
|
|
41625
41771
|
return {};
|
|
41626
41772
|
},
|
|
41627
|
-
additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys
|
|
41773
|
+
additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys,
|
|
41774
|
+
getAdditionalEnvVars: function (_a) {
|
|
41775
|
+
var _b;
|
|
41776
|
+
|
|
41777
|
+
var componentName = _a.componentName,
|
|
41778
|
+
fullConfig = _a.fullConfig,
|
|
41779
|
+
deployConfig = _a.deployConfig,
|
|
41780
|
+
env = _a.env,
|
|
41781
|
+
envType = _a.envType,
|
|
41782
|
+
commitInfo = _a.commitInfo;
|
|
41783
|
+
var KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
|
|
41784
|
+
var KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
|
|
41785
|
+
var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
|
|
41786
|
+
var componentSlug = (0, slugify_1["default"])(componentName);
|
|
41787
|
+
var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
|
|
41788
|
+
var domainCanonical = deployConfig && ((_b = deployConfig.cluster) === null || _b === void 0 ? void 0 : _b.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
|
|
41789
|
+
fullConfig.domainCanonical || "panter.cloud";
|
|
41790
|
+
var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
|
|
41791
|
+
|
|
41792
|
+
return {
|
|
41793
|
+
KUBE_NAMESPACE: KUBE_NAMESPACE,
|
|
41794
|
+
KUBE_APP_NAME: KUBE_APP_NAME,
|
|
41795
|
+
KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
|
|
41796
|
+
HOST_CANONICAL: HOST_CANONICAL
|
|
41797
|
+
};
|
|
41798
|
+
}
|
|
41628
41799
|
};
|
|
41629
41800
|
|
|
41630
41801
|
/***/ }),
|