@catladder/cli 0.0.0-main-3b6d4049 → 0.0.0-main-5f142cf2
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/catenv/catenv.js +15 -12
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/shell/commands/mongodb/projectMongoDestroyMember.js +6 -6
- package/dist/apps/shell/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
- package/dist/apps/shell/commands/mongodb/projectMongoGetShell.js +6 -6
- package/dist/apps/shell/commands/mongodb/projectMongoGetShell.js.map +1 -1
- package/dist/apps/shell/commands/mongodb/projectMongoPortForward.js +5 -5
- package/dist/apps/shell/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/apps/shell/commands/mongodb/utils/index.d.ts +3 -4
- package/dist/apps/shell/commands/mongodb/utils/index.js +6 -6
- package/dist/apps/shell/commands/mongodb/utils/index.js.map +1 -1
- package/dist/apps/shell/commands/project/commandCloudSqlProxy.js +10 -7
- package/dist/apps/shell/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/shell/commands/project/commandConfigSecrets.js +46 -176
- package/dist/apps/shell/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/shell/commands/project/commandCopyDB.js +1 -1
- package/dist/apps/shell/commands/project/commandCopyDB.js.map +1 -1
- package/dist/apps/shell/commands/project/commandDeletePods.js +5 -5
- package/dist/apps/shell/commands/project/commandDeletePods.js.map +1 -1
- package/dist/apps/shell/commands/project/commandDeleteProject.js +3 -3
- package/dist/apps/shell/commands/project/commandDeleteProject.js.map +1 -1
- package/dist/apps/shell/commands/project/commandGetShell.js +6 -6
- package/dist/apps/shell/commands/project/commandGetShell.js.map +1 -1
- package/dist/apps/shell/commands/project/commandInitGitlab.js +64 -38
- package/dist/apps/shell/commands/project/commandInitGitlab.js.map +1 -1
- package/dist/apps/shell/commands/project/commandInitProject.js +138 -129
- package/dist/apps/shell/commands/project/commandInitProject.js.map +1 -1
- package/dist/apps/shell/commands/project/commandListPods.js +5 -5
- package/dist/apps/shell/commands/project/commandListPods.js.map +1 -1
- package/dist/apps/shell/commands/project/commandMigrateHelm3.js +1 -1
- package/dist/apps/shell/commands/project/commandMigrateHelm3.js.map +1 -1
- package/dist/apps/shell/commands/project/commandNamespace.js +3 -3
- package/dist/apps/shell/commands/project/commandNamespace.js.map +1 -1
- package/dist/apps/shell/commands/project/commandOpenCostDashboard.js +4 -4
- package/dist/apps/shell/commands/project/commandOpenCostDashboard.js.map +1 -1
- package/dist/apps/shell/commands/project/commandOpenDashboard.js +11 -5
- package/dist/apps/shell/commands/project/commandOpenDashboard.js.map +1 -1
- package/dist/apps/shell/commands/project/commandOpenEnv.js +1 -1
- package/dist/apps/shell/commands/project/commandOpenEnv.js.map +1 -1
- package/dist/apps/shell/commands/project/commandOpenGrafana.js +4 -4
- package/dist/apps/shell/commands/project/commandOpenGrafana.js.map +1 -1
- package/dist/apps/shell/commands/project/commandOpenGrafanaPod.js +5 -5
- package/dist/apps/shell/commands/project/commandOpenGrafanaPod.js.map +1 -1
- package/dist/apps/shell/commands/project/commandOpenLogs.js +4 -4
- package/dist/apps/shell/commands/project/commandOpenLogs.js.map +1 -1
- package/dist/apps/shell/commands/project/commandPauseProject.js +3 -3
- package/dist/apps/shell/commands/project/commandPauseProject.js.map +1 -1
- package/dist/apps/shell/commands/project/commandPortForward.js +5 -5
- package/dist/apps/shell/commands/project/commandPortForward.js.map +1 -1
- package/dist/apps/shell/commands/project/commandTriggerCronjob.js +4 -4
- package/dist/apps/shell/commands/project/commandTriggerCronjob.js.map +1 -1
- package/dist/apps/shell/commands/project/index.js +0 -2
- package/dist/apps/shell/commands/project/index.js.map +1 -1
- package/dist/apps/shell/commands/project/utils/ensureCluster.d.ts +1 -1
- package/dist/apps/shell/commands/project/utils/ensureCluster.js +12 -10
- package/dist/apps/shell/commands/project/utils/ensureCluster.js.map +1 -1
- package/dist/apps/shell/commands/project/utils/ensureNamespace.d.ts +1 -2
- package/dist/apps/shell/commands/project/utils/ensureNamespace.js +2 -2
- package/dist/apps/shell/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +7 -4
- package/dist/config/getProjectConfig.js +35 -11
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +0 -1
- package/dist/utils/cluster.d.ts +7 -0
- package/dist/utils/cluster.js +15 -3
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/editAsFile.d.ts +1 -0
- package/dist/utils/editAsFile.js +22 -0
- package/dist/utils/editAsFile.js.map +1 -0
- package/dist/utils/gitlab.d.ts +2 -1
- package/dist/utils/gitlab.js +29 -3
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/projects/index.d.ts +4 -15
- package/dist/utils/projects/index.js +10 -78
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +1 -1
- package/src/apps/catenv/catenv.ts +36 -26
- package/src/apps/shell/commands/mongodb/projectMongoDestroyMember.ts +6 -6
- package/src/apps/shell/commands/mongodb/projectMongoGetShell.ts +9 -7
- package/src/apps/shell/commands/mongodb/projectMongoPortForward.ts +10 -5
- package/src/apps/shell/commands/mongodb/utils/index.ts +9 -8
- package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +14 -7
- package/src/apps/shell/commands/project/commandConfigSecrets.ts +37 -172
- package/src/apps/shell/commands/project/commandCopyDB.ts +2 -1
- package/src/apps/shell/commands/project/commandDeletePods.ts +5 -6
- package/src/apps/shell/commands/project/commandDeleteProject.ts +4 -5
- package/src/apps/shell/commands/project/commandGetShell.ts +7 -7
- package/src/apps/shell/commands/project/commandInitGitlab.ts +97 -51
- package/src/apps/shell/commands/project/commandInitProject.ts +8 -0
- package/src/apps/shell/commands/project/commandListPods.ts +5 -6
- package/src/apps/shell/commands/project/commandMigrateHelm3.ts +1 -1
- package/src/apps/shell/commands/project/commandNamespace.ts +6 -4
- package/src/apps/shell/commands/project/commandOpenCostDashboard.ts +7 -4
- package/src/apps/shell/commands/project/commandOpenDashboard.ts +18 -6
- package/src/apps/shell/commands/project/commandOpenEnv.ts +1 -1
- package/src/apps/shell/commands/project/commandOpenGrafana.ts +4 -4
- package/src/apps/shell/commands/project/commandOpenGrafanaPod.ts +5 -5
- package/src/apps/shell/commands/project/commandOpenLogs.ts +4 -4
- package/src/apps/shell/commands/project/commandPauseProject.ts +6 -4
- package/src/apps/shell/commands/project/commandPortForward.ts +5 -5
- package/src/apps/shell/commands/project/commandTriggerCronjob.ts +4 -4
- package/src/apps/shell/commands/project/index.ts +1 -2
- package/src/apps/shell/commands/project/utils/ensureCluster.ts +12 -10
- package/src/apps/shell/commands/project/utils/ensureNamespace.ts +2 -3
- package/src/config/getProjectConfig.ts +40 -11
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +15 -2
- package/src/utils/editAsFile.ts +21 -0
- package/src/utils/gitlab.ts +56 -4
- package/src/utils/projects/index.ts +10 -93
- package/dist/apps/shell/commands/project/commandVariables.d.ts +0 -3
- package/dist/apps/shell/commands/project/commandVariables.js +0 -16
- package/dist/apps/shell/commands/project/commandVariables.js.map +0 -1
- package/dist/apps/shell/commands/project/utils/monorepo.d.ts +0 -10
- package/dist/apps/shell/commands/project/utils/monorepo.js +0 -25
- package/dist/apps/shell/commands/project/utils/monorepo.js.map +0 -1
- package/src/apps/shell/commands/project/commandVariables.ts +0 -13
- package/src/apps/shell/commands/project/utils/monorepo.ts +0 -23
package/dist/types/types.d.ts
CHANGED
package/dist/utils/cluster.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export declare const getCurrentContext: () => Promise<any>;
|
|
2
2
|
export declare const getCurrentConnectedClusterName: () => Promise<string>;
|
|
3
|
+
export declare const getClusterByFullName: (fullName: string) => {
|
|
4
|
+
name: string;
|
|
5
|
+
cluster: import("../config/clusters").Cluster;
|
|
6
|
+
};
|
|
3
7
|
export declare const getClusterByName: (name: string) => import("../config/clusters").Cluster;
|
|
8
|
+
export declare const getAllClusters: () => {
|
|
9
|
+
[clustername: string]: import("../config/clusters").Cluster;
|
|
10
|
+
};
|
|
4
11
|
export declare const getAllClusterNames: () => string[];
|
|
5
12
|
export declare const connectToCluster: (clusterName: string) => Promise<void>;
|
package/dist/utils/cluster.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.connectToCluster = exports.getAllClusterNames = exports.getClusterByName = exports.getCurrentConnectedClusterName = exports.getCurrentContext = void 0;
|
|
6
|
+
exports.connectToCluster = exports.getAllClusterNames = exports.getAllClusters = exports.getClusterByName = exports.getClusterByFullName = exports.getCurrentConnectedClusterName = exports.getCurrentContext = void 0;
|
|
7
7
|
const child_process_promise_1 = require("child-process-promise");
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const clusters_1 = __importDefault(require("../config/clusters"));
|
|
@@ -14,10 +14,22 @@ const getCurrentConnectedClusterName = async () => {
|
|
|
14
14
|
return (0, lodash_1.findKey)(clusters_1.default, { fullName: currentContext });
|
|
15
15
|
};
|
|
16
16
|
exports.getCurrentConnectedClusterName = getCurrentConnectedClusterName;
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const getClusterByFullName = (fullName) => {
|
|
18
|
+
const found = Object.entries((0, exports.getAllClusters)()).find(([, config]) => config.fullName === fullName);
|
|
19
|
+
if (found) {
|
|
20
|
+
return { name: found[0], cluster: found[1] };
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
19
25
|
};
|
|
26
|
+
exports.getClusterByFullName = getClusterByFullName;
|
|
27
|
+
const getClusterByName = (name) => (0, exports.getAllClusters)()[name];
|
|
20
28
|
exports.getClusterByName = getClusterByName;
|
|
29
|
+
const getAllClusters = () => {
|
|
30
|
+
return clusters_1.default;
|
|
31
|
+
};
|
|
32
|
+
exports.getAllClusters = getAllClusters;
|
|
21
33
|
const getAllClusterNames = () => Object.keys(clusters_1.default);
|
|
22
34
|
exports.getAllClusterNames = getAllClusterNames;
|
|
23
35
|
const connectToCluster = async (clusterName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/utils/cluster.ts"],"names":[],"mappings":";;;;;;AAAA,iEAA6C;AAC7C,mCAAiC;AACjC,kEAA0C;AACnC,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE,CAC1C,CAAC,MAAM,IAAA,4BAAI,EAAC,gCAAgC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AADlD,QAAA,iBAAiB,qBACiC;AAExD,MAAM,8BAA8B,GAAG,KAAK,IAAI,EAAE;IACvD,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IACjD,OAAO,IAAA,gBAAO,EAAC,kBAAQ,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAHW,QAAA,8BAA8B,kCAGzC;AAEK,MAAM,
|
|
1
|
+
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/utils/cluster.ts"],"names":[],"mappings":";;;;;;AAAA,iEAA6C;AAC7C,mCAAiC;AACjC,kEAA0C;AACnC,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE,CAC1C,CAAC,MAAM,IAAA,4BAAI,EAAC,gCAAgC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AADlD,QAAA,iBAAiB,qBACiC;AAExD,MAAM,8BAA8B,GAAG,KAAK,IAAI,EAAE;IACvD,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IACjD,OAAO,IAAA,gBAAO,EAAC,kBAAQ,EAAE,EAAE,QAAQ,EAAE,cAAc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__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.editAsFile = void 0;
|
|
7
|
+
const tmp_promise_1 = require("tmp-promise");
|
|
8
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
|
+
const fs_extra_1 = require("fs-extra");
|
|
10
|
+
const getEditor_1 = __importDefault(require("./getEditor"));
|
|
11
|
+
const editAsFile = async (inObject) => {
|
|
12
|
+
const asString = js_yaml_1.default.safeDump(inObject);
|
|
13
|
+
let newContent;
|
|
14
|
+
await (0, tmp_promise_1.withFile)(async ({ path: tmpFilePath }) => {
|
|
15
|
+
await (0, fs_extra_1.writeFile)(tmpFilePath, asString);
|
|
16
|
+
await (await (0, getEditor_1.default)()).open(tmpFilePath);
|
|
17
|
+
newContent = js_yaml_1.default.load((await (0, fs_extra_1.readFile)(tmpFilePath)).toString("utf-8"));
|
|
18
|
+
}, { postfix: ".yml" });
|
|
19
|
+
return newContent;
|
|
20
|
+
};
|
|
21
|
+
exports.editAsFile = editAsFile;
|
|
22
|
+
//# sourceMappingURL=editAsFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editAsFile.js","sourceRoot":"","sources":["../../src/utils/editAsFile.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAuC;AACvC,sDAA2B;AAE3B,uCAA+C;AAC/C,4DAAoC;AAE7B,MAAM,UAAU,GAAG,KAAK,EAAK,QAAW,EAAc,EAAE;IAC7D,MAAM,QAAQ,GAAG,iBAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,UAAU,CAAC;IAEf,MAAM,IAAA,sBAAQ,EACZ,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;QAC9B,MAAM,IAAA,oBAAS,EAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,IAAA,mBAAS,GAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,UAAU,GAAG,iBAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAA,mBAAQ,EAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1E,CAAC,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,CACpB,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAdW,QAAA,UAAU,cAcrB"}
|
package/dist/utils/gitlab.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandInstance } from "vorpal";
|
|
2
2
|
export declare const getGitlabToken: (vorpal: CommandInstance) => Promise<any>;
|
|
3
|
-
export declare const doGitlabRequest: (vorpal: CommandInstance, path: string, data?: any) => Promise<
|
|
3
|
+
export declare const doGitlabRequest: <T = any>(vorpal: CommandInstance, path: string, data?: any, update?: boolean) => Promise<T>;
|
|
4
4
|
export declare const getProjectInfo: (vorpal: CommandInstance) => Promise<{
|
|
5
5
|
id: string;
|
|
6
6
|
web_url: string;
|
|
@@ -14,4 +14,5 @@ declare type GitlabVariable = {
|
|
|
14
14
|
environment_scope: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const getAllVariables: (vorpal: CommandInstance) => Promise<Array<GitlabVariable>>;
|
|
17
|
+
export declare const upsertAllVariables: (vorpal: CommandInstance, variables: Record<string, string>, env: string, componentName: string) => Promise<void>;
|
|
17
18
|
export {};
|
package/dist/utils/gitlab.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = void 0;
|
|
6
|
+
exports.upsertAllVariables = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = void 0;
|
|
7
7
|
const child_process_promise_1 = require("child-process-promise");
|
|
8
8
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
9
|
const open_1 = __importDefault(require("open"));
|
|
@@ -38,10 +38,11 @@ const getGitlabToken = async (vorpal) => {
|
|
|
38
38
|
return (0, preferences_1.getPreference)(TOKEN_KEY);
|
|
39
39
|
};
|
|
40
40
|
exports.getGitlabToken = getGitlabToken;
|
|
41
|
-
const doGitlabRequest = async (vorpal, path, data) => {
|
|
41
|
+
const doGitlabRequest = async (vorpal, path, data = undefined, update) => {
|
|
42
42
|
const rootToken = await (0, exports.getGitlabToken)(vorpal);
|
|
43
|
+
const method = data ? (update ? "PUT" : "POST") : "GET";
|
|
43
44
|
const result = await (0, node_fetch_1.default)(`https://git.panter.ch/api/v4/${path}`, {
|
|
44
|
-
method
|
|
45
|
+
method,
|
|
45
46
|
headers: {
|
|
46
47
|
"Content-Type": "application/json",
|
|
47
48
|
"Private-Token": rootToken,
|
|
@@ -66,4 +67,29 @@ const getAllVariables = async (vorpal) => {
|
|
|
66
67
|
return await (0, exports.doGitlabRequest)(this, `projects/${id}/variables`);
|
|
67
68
|
};
|
|
68
69
|
exports.getAllVariables = getAllVariables;
|
|
70
|
+
const createVariable = async (vorpal, projectId, key, value) => {
|
|
71
|
+
return await (0, exports.doGitlabRequest)(this, `projects/${projectId}/variables`, {
|
|
72
|
+
key,
|
|
73
|
+
value,
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const updateVariable = async (vorpal, projectId, key, value) => {
|
|
77
|
+
return await (0, exports.doGitlabRequest)(this, `projects/${projectId}/variables/${key}`, {
|
|
78
|
+
value,
|
|
79
|
+
}, true);
|
|
80
|
+
};
|
|
81
|
+
const upsertAllVariables = async (vorpal, variables, env, componentName) => {
|
|
82
|
+
const { id } = await (0, exports.getProjectInfo)(vorpal);
|
|
83
|
+
console.log("upsertAllVariables", variables);
|
|
84
|
+
for (const [key, value] of Object.entries(variables ?? {})) {
|
|
85
|
+
const fullKey = "CL_" + env + "_" + componentName + "_" + key;
|
|
86
|
+
try {
|
|
87
|
+
await updateVariable(vorpal, id, fullKey, value);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
await createVariable(vorpal, id, fullKey, value);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.upsertAllVariables = upsertAllVariables;
|
|
69
95
|
//# sourceMappingURL=gitlab.js.map
|
package/dist/utils/gitlab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.js","sourceRoot":"","sources":["../../src/utils/gitlab.ts"],"names":[],"mappings":";;;;;;AAAA,iEAA6C;AAC7C,4DAA+B;AAC/B,gDAAwB;AAExB,+CAA4E;AAE5E,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAC1C,MAAM,cAAc,GAAG,KAAK,EAAE,MAAuB,EAAE,EAAE;IAC9D,IAAI,CAAC,CAAC,MAAM,IAAA,2BAAa,EAAC,SAAS,CAAC,CAAC,EAAE;QACrC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,CACR,+DAA+D,CAChE,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QAChE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACf,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YAC7C,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;QAEH,IAAA,cAAI,EAAC,wDAAwD,CAAC,CAAC;QAE/D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B,IAAI,EACJ,YAAY,SAAS,cAAc,GAAG,EAAE,EACxC;QACE,KAAK;KACN,EACD,IAAI,CACL,CAAC;AACJ,CAAC,CAAC;AACK,MAAM,kBAAkB,GAAG,KAAK,EACrC,MAAuB,EACvB,SAAiC,EACjC,GAAW,EACX,aAAqB,EACN,EAAE;IACjB,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC;IAE5C,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;IAE7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE;QAC1D,MAAM,OAAO,GAAG,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,aAAa,GAAG,GAAG,GAAG,GAAG,CAAC;QAE9D,IAAI;YACF,MAAM,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;SAClD;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;SAClD;KACF;AACH,CAAC,CAAC;AAnBW,QAAA,kBAAkB,sBAmB7B"}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import { Env, ISecrets, IValueFile } from "../../types/types";
|
|
2
1
|
export declare const getGitRoot: () => Promise<any>;
|
|
3
2
|
export declare const getRootGitlabCiFile: () => Promise<string>;
|
|
4
3
|
export declare const readRootGitlabCiFile: () => Promise<any[]>;
|
|
5
4
|
export declare const hasGitlabCiFile: () => Promise<boolean>;
|
|
6
|
-
export declare const getProjectNamespace: (
|
|
7
|
-
export declare const getProjectPods: (
|
|
8
|
-
export declare const getProjectPvcs: (
|
|
9
|
-
export declare const getProjectPodNames: (
|
|
10
|
-
export declare const getPassPath: (env: Env) => Promise<string>;
|
|
11
|
-
export declare const getProjectValuesFiles: (env: Env, subApp?: string) => Promise<string[]>;
|
|
12
|
-
export declare const getAllValues: (env: Env, subApp?: string) => Promise<IValueFile[]>;
|
|
13
|
-
export declare const getProjectValues: (env: Env, subApp?: string) => Promise<IValueFile>;
|
|
14
|
-
export declare const getAllPublicEnvVars: (env: Env, subApp?: string) => Promise<{}>;
|
|
15
|
-
export declare const getAllSecretsEnvVarsMapping: (env: Env, subApp?: string) => Promise<ISecrets>;
|
|
16
|
-
export declare const hasSecrets: (env: Env, subApp?: string) => Promise<boolean>;
|
|
17
|
-
export declare const getAllEnvVars: (env: Env, subApp?: string) => Promise<Record<string, string>>;
|
|
18
|
-
export declare const getAllSecretEnvVars: (env: Env, subApp?: string) => Promise<never>;
|
|
19
|
-
export declare const getLocalProjectVariables: () => never;
|
|
5
|
+
export declare const getProjectNamespace: (envComponent: string) => Promise<string>;
|
|
6
|
+
export declare const getProjectPods: (envComponent: string) => Promise<import("@kubernetes/client-node").V1Pod[]>;
|
|
7
|
+
export declare const getProjectPvcs: (envComponent: string) => Promise<import("@kubernetes/client-node").V1PersistentVolumeClaim[]>;
|
|
8
|
+
export declare const getProjectPodNames: (envComponent: string) => Promise<string[]>;
|
|
@@ -3,17 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getProjectPodNames = exports.getProjectPvcs = exports.getProjectPods = exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
|
|
7
7
|
const child_process_promise_1 = require("child-process-promise");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const getProjectConfig_1 = require("../../config/getProjectConfig");
|
|
9
10
|
const k8sApi_1 = __importDefault(require("../../k8sApi"));
|
|
10
11
|
const files_1 = require("../files");
|
|
11
|
-
const formatEnvVars_1 = __importDefault(require("../formatEnvVars"));
|
|
12
|
-
const promise_1 = require("../promise");
|
|
13
|
-
const lodash_1 = require("lodash");
|
|
14
|
-
const getProjectConfig_1 = require("../../config/getProjectConfig");
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
|
-
const YAWN = require("yawn-yaml/cjs");
|
|
17
12
|
const getGitRoot = async () => {
|
|
18
13
|
return (await (0, child_process_promise_1.exec)("git rev-parse --show-toplevel")).stdout?.trim();
|
|
19
14
|
};
|
|
@@ -33,90 +28,27 @@ const hasGitlabCiFile = async () => {
|
|
|
33
28
|
return true;
|
|
34
29
|
};
|
|
35
30
|
exports.hasGitlabCiFile = hasGitlabCiFile;
|
|
36
|
-
const getProjectNamespace = async (
|
|
31
|
+
const getProjectNamespace = async (envComponent) => {
|
|
32
|
+
const { env } = (0, getProjectConfig_1.parseChoice)(envComponent);
|
|
37
33
|
const config = (0, getProjectConfig_1.getProjectConfig)();
|
|
38
34
|
return `${config.customerName}-${config.appName}-${env}`;
|
|
39
35
|
};
|
|
40
36
|
exports.getProjectNamespace = getProjectNamespace;
|
|
41
|
-
const getProjectPods = async (
|
|
42
|
-
const namespace = await (0, exports.getProjectNamespace)(
|
|
37
|
+
const getProjectPods = async (envComponent) => {
|
|
38
|
+
const namespace = await (0, exports.getProjectNamespace)(envComponent);
|
|
43
39
|
const res = await k8sApi_1.default.listNamespacedPod(namespace);
|
|
44
40
|
return res.body.items;
|
|
45
41
|
};
|
|
46
42
|
exports.getProjectPods = getProjectPods;
|
|
47
|
-
const getProjectPvcs = async (
|
|
48
|
-
const namespace = await (0, exports.getProjectNamespace)(
|
|
43
|
+
const getProjectPvcs = async (envComponent) => {
|
|
44
|
+
const namespace = await (0, exports.getProjectNamespace)(envComponent);
|
|
49
45
|
const res = await k8sApi_1.default.listNamespacedPersistentVolumeClaim(namespace);
|
|
50
46
|
return res.body.items;
|
|
51
47
|
};
|
|
52
48
|
exports.getProjectPvcs = getProjectPvcs;
|
|
53
|
-
const getProjectPodNames = async (
|
|
54
|
-
const pods = await (0, exports.getProjectPods)(
|
|
49
|
+
const getProjectPodNames = async (envComponent) => {
|
|
50
|
+
const pods = await (0, exports.getProjectPods)(envComponent);
|
|
55
51
|
return pods.map((n) => n.metadata.name);
|
|
56
52
|
};
|
|
57
53
|
exports.getProjectPodNames = getProjectPodNames;
|
|
58
|
-
const getPassPath = async (env) => {
|
|
59
|
-
const { CUSTOMER_NAME, APP_NAME } = await (0, exports.getLocalProjectVariables)();
|
|
60
|
-
return `${CUSTOMER_NAME}/${APP_NAME}/${env}/secrets.yml`;
|
|
61
|
-
};
|
|
62
|
-
exports.getPassPath = getPassPath;
|
|
63
|
-
const getProjectValuesFiles = async (env, subApp) => {
|
|
64
|
-
const gitRoot = await (0, exports.getGitRoot)();
|
|
65
|
-
const possibleFiles = ["values.yml", `values-${env}.yml`].map((file) => subApp ? (0, path_1.join)(gitRoot, subApp, file) : (0, path_1.join)(gitRoot, file));
|
|
66
|
-
return (0, promise_1.filter)(possibleFiles, async (file) => {
|
|
67
|
-
const [error] = await (0, files_1.readFileOrError)(file);
|
|
68
|
-
return !error;
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
exports.getProjectValuesFiles = getProjectValuesFiles;
|
|
72
|
-
const getAllValues = async (env, subApp) => {
|
|
73
|
-
const valuesFilePaths = await (0, exports.getProjectValuesFiles)(env, subApp);
|
|
74
|
-
return Promise.all(valuesFilePaths.map(async (file) => (await (0, files_1.readYaml)(file))));
|
|
75
|
-
};
|
|
76
|
-
exports.getAllValues = getAllValues;
|
|
77
|
-
const getProjectValues = async (env, subApp) => {
|
|
78
|
-
const values = await (0, exports.getAllValues)(env, subApp);
|
|
79
|
-
return (0, lodash_1.merge)({}, ...values);
|
|
80
|
-
};
|
|
81
|
-
exports.getProjectValues = getProjectValues;
|
|
82
|
-
const getAllPublicEnvVars = async (env, subApp) => {
|
|
83
|
-
return (0, formatEnvVars_1.default)((await (0, exports.getAllValues)(env, subApp)).reduce((acc, value) => {
|
|
84
|
-
if (value.env && value.env.public) {
|
|
85
|
-
return {
|
|
86
|
-
...acc,
|
|
87
|
-
...value.env.public,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return acc;
|
|
91
|
-
}, {}));
|
|
92
|
-
};
|
|
93
|
-
exports.getAllPublicEnvVars = getAllPublicEnvVars;
|
|
94
|
-
const getAllSecretsEnvVarsMapping = async (env, subApp) => {
|
|
95
|
-
return (await (0, exports.getAllValues)(env, subApp)).reduce((acc, value) => {
|
|
96
|
-
if (value.env && value.env.secret) {
|
|
97
|
-
return {
|
|
98
|
-
...acc,
|
|
99
|
-
...value.env.secret,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return acc;
|
|
103
|
-
}, {});
|
|
104
|
-
};
|
|
105
|
-
exports.getAllSecretsEnvVarsMapping = getAllSecretsEnvVarsMapping;
|
|
106
|
-
const hasSecrets = async (env, subApp) => {
|
|
107
|
-
return Object.keys(await (0, exports.getAllSecretsEnvVarsMapping)(env, subApp)).length > 0;
|
|
108
|
-
};
|
|
109
|
-
exports.hasSecrets = hasSecrets;
|
|
110
|
-
const getAllEnvVars = async (env, subApp) => {
|
|
111
|
-
throw new Error("needs to be re-implemented");
|
|
112
|
-
};
|
|
113
|
-
exports.getAllEnvVars = getAllEnvVars;
|
|
114
|
-
const getAllSecretEnvVars = async (env, subApp) => {
|
|
115
|
-
throw new Error("needs to be re-implemented");
|
|
116
|
-
};
|
|
117
|
-
exports.getAllSecretEnvVars = getAllSecretEnvVars;
|
|
118
|
-
const getLocalProjectVariables = () => {
|
|
119
|
-
throw new Error("use getProjectConfig");
|
|
120
|
-
};
|
|
121
|
-
exports.getLocalProjectVariables = getLocalProjectVariables;
|
|
122
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":";;;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E,CAAC;AAC3D,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B;AAEK,MAAM,cAAc,GAAG,KAAK,EAAE,YAAoB,EAAE,EAAE;IAC3D,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,MAAM,gBAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAEtD,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;AACxB,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,MAAM,cAAc,GAAG,KAAK,EAAE,YAAoB,EAAE,EAAE;IAC3D,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,MAAM,gBAAM,CAAC,mCAAmC,CAAC,SAAS,CAAC,CAAC;IAExE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;AACxB,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,MAAM,kBAAkB,GAAG,KAAK,EAAE,YAAoB,EAAE,EAAE;IAC/D,MAAM,IAAI,GAAG,MAAM,IAAA,sBAAc,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ComponentConfig } from "@catladder/pipeline";
|
|
2
|
+
import { getEnvVars, getProjectConfig } from "../../config/getProjectConfig";
|
|
3
|
+
import { getGitRoot } from "../../utils/projects";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
const getCurrentComponentName = async (
|
|
6
|
+
components: Record<string, ComponentConfig>
|
|
7
|
+
) => {
|
|
8
|
+
const gitRoot = await getGitRoot();
|
|
9
|
+
const currentDir = process.cwd();
|
|
10
|
+
return Object.keys(components).find((c) =>
|
|
11
|
+
currentDir.startsWith(join(gitRoot, components[c].dir))
|
|
12
|
+
);
|
|
13
|
+
};
|
|
6
14
|
|
|
7
15
|
const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
|
|
8
16
|
export default async () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
17
|
+
const { components } = getProjectConfig();
|
|
18
|
+
|
|
19
|
+
const currentComponent = await getCurrentComponentName(components);
|
|
11
20
|
let variables = {};
|
|
12
|
-
if (
|
|
13
|
-
variables = await
|
|
14
|
-
} else
|
|
21
|
+
if (currentComponent) {
|
|
22
|
+
variables = await getEnvVars(null, "dev-local:" + currentComponent);
|
|
23
|
+
} else {
|
|
15
24
|
// when in a monorep and not in a subapp, merge all env vars.
|
|
16
25
|
// this is not 100% correct, but better than not exporting any vars at all
|
|
17
26
|
// so we also add prefixed variants
|
|
18
|
-
variables = await
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Object.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
variables = await Object.keys(components).reduce(
|
|
28
|
+
async (acc, componentName) => {
|
|
29
|
+
const subappvars = await getEnvVars(null, "dev-local:" + componentName);
|
|
30
|
+
return {
|
|
31
|
+
...(await acc),
|
|
32
|
+
...subappvars,
|
|
33
|
+
// also add prefixed variants in case
|
|
34
|
+
...Object.fromEntries(
|
|
35
|
+
Object.entries(subappvars).map(([key, value]) => [
|
|
36
|
+
`${sanitizeEnvVarName(componentName.toUpperCase())}_${key}`,
|
|
37
|
+
value,
|
|
38
|
+
])
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
{}
|
|
43
|
+
);
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
console.log(
|
|
@@ -37,12 +37,12 @@ const removeFinalizerAndDelete = async (
|
|
|
37
37
|
export default (vorpal: Vorpal) =>
|
|
38
38
|
vorpal
|
|
39
39
|
.command(
|
|
40
|
-
"project-mongo-destroy-member <
|
|
40
|
+
"project-mongo-destroy-member <envComponent>",
|
|
41
41
|
"DESTROY a member of a replicaset in order to reinitialize it"
|
|
42
42
|
)
|
|
43
43
|
.autocomplete(envAutocompletion)
|
|
44
|
-
.action(async function ({
|
|
45
|
-
await ensureCluster.call(this);
|
|
44
|
+
.action(async function ({ envComponent }) {
|
|
45
|
+
await ensureCluster.call(this, envComponent);
|
|
46
46
|
this.log(
|
|
47
47
|
"this command tries to delete a (secondary) member of the replicaset, it's persistent volume claim (pvc) and the volume"
|
|
48
48
|
);
|
|
@@ -74,10 +74,10 @@ export default (vorpal: Vorpal) =>
|
|
|
74
74
|
throw new Error("abort");
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const namespace = await getProjectNamespace(
|
|
78
|
-
const mongodbPods = await getMongoDbPodsWithReplInfo(
|
|
77
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
78
|
+
const mongodbPods = await getMongoDbPodsWithReplInfo(envComponent);
|
|
79
79
|
|
|
80
|
-
const pvcs = await getProjectPvcs(
|
|
80
|
+
const pvcs = await getProjectPvcs(envComponent);
|
|
81
81
|
const secondaries = mongodbPods.filter((pod) => !pod.isMaster);
|
|
82
82
|
|
|
83
83
|
if (secondaries.length === 0) {
|
|
@@ -5,20 +5,22 @@ import { envAutocompletion } from "../project/utils/autocompletions";
|
|
|
5
5
|
import ensureCluster from "../project/utils/ensureCluster";
|
|
6
6
|
import {
|
|
7
7
|
getMongodbShell,
|
|
8
|
-
getProjectMongodbAllPodsSortedWithLabel
|
|
8
|
+
getProjectMongodbAllPodsSortedWithLabel,
|
|
9
9
|
} from "./utils";
|
|
10
10
|
|
|
11
11
|
export default (vorpal: Vorpal) =>
|
|
12
12
|
vorpal
|
|
13
13
|
.command(
|
|
14
|
-
"project-mongo-get-shell <
|
|
14
|
+
"project-mongo-get-shell <envComponent>",
|
|
15
15
|
"get a shell to a mongodb in the environment"
|
|
16
16
|
)
|
|
17
17
|
.autocomplete(envAutocompletion)
|
|
18
|
-
.action(async function({
|
|
19
|
-
await ensureCluster.call(this);
|
|
20
|
-
const namespace = await getProjectNamespace(
|
|
21
|
-
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
18
|
+
.action(async function ({ envComponent }) {
|
|
19
|
+
await ensureCluster.call(this, envComponent);
|
|
20
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
21
|
+
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
22
|
+
envComponent
|
|
23
|
+
);
|
|
22
24
|
if (podNames.length === 0) {
|
|
23
25
|
logError(this, "sorry, no pods found");
|
|
24
26
|
return;
|
|
@@ -32,7 +34,7 @@ export default (vorpal: Vorpal) =>
|
|
|
32
34
|
type: "list",
|
|
33
35
|
name: "podName",
|
|
34
36
|
choices: podNames,
|
|
35
|
-
message: "Which pod? 🤔"
|
|
37
|
+
message: "Which pod? 🤔",
|
|
36
38
|
})
|
|
37
39
|
).podName;
|
|
38
40
|
}
|
|
@@ -8,12 +8,17 @@ import { getProjectMongodbAllPodsSortedWithLabel } from "./utils";
|
|
|
8
8
|
|
|
9
9
|
export default (vorpal: Vorpal) =>
|
|
10
10
|
vorpal
|
|
11
|
-
.command(
|
|
11
|
+
.command(
|
|
12
|
+
"project-mongo-port-forward <envComponent>",
|
|
13
|
+
"port foward to a mongodb"
|
|
14
|
+
)
|
|
12
15
|
.autocomplete(envAutocompletion)
|
|
13
|
-
.action(async function ({
|
|
14
|
-
await ensureCluster.call(this);
|
|
15
|
-
const namespace = await getProjectNamespace(
|
|
16
|
-
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
16
|
+
.action(async function ({ envComponent }) {
|
|
17
|
+
await ensureCluster.call(this, envComponent);
|
|
18
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
19
|
+
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
20
|
+
envComponent
|
|
21
|
+
);
|
|
17
22
|
if (podNames.length === 0) {
|
|
18
23
|
logError(this, "sorry, no pods found");
|
|
19
24
|
return;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { exec, spawn } from "child-process-promise";
|
|
2
|
-
import { Env } from "../../../../../types/types";
|
|
3
2
|
import {
|
|
4
3
|
getProjectNamespace,
|
|
5
4
|
getProjectPodNames,
|
|
@@ -8,8 +7,8 @@ import {
|
|
|
8
7
|
const filterMongoDbs = (podNames: string[]) =>
|
|
9
8
|
podNames.filter((name) => name.includes("mongodb-replicaset"));
|
|
10
9
|
|
|
11
|
-
export const getProjectMongodbAllPods = async (
|
|
12
|
-
filterMongoDbs(await getProjectPodNames(
|
|
10
|
+
export const getProjectMongodbAllPods = async (envComponent: string) =>
|
|
11
|
+
filterMongoDbs(await getProjectPodNames(envComponent));
|
|
13
12
|
|
|
14
13
|
export const getMongodbShell = async (namespace: string, podName: string) => {
|
|
15
14
|
const command = `kubectl exec -it ${podName} --namespace ${namespace} mongo`;
|
|
@@ -55,12 +54,12 @@ export const podIsMaster = async (namespace: string, podName: string) => {
|
|
|
55
54
|
|
|
56
55
|
const spaces = (n: number) => " ".repeat(n);
|
|
57
56
|
|
|
58
|
-
export const getMongoDbPodsWithReplInfo = async (
|
|
59
|
-
const namespace = await getProjectNamespace(
|
|
57
|
+
export const getMongoDbPodsWithReplInfo = async (envComponent: string) => {
|
|
58
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
60
59
|
return (
|
|
61
60
|
await Promise.all(
|
|
62
61
|
(
|
|
63
|
-
await getProjectMongodbAllPods(
|
|
62
|
+
await getProjectMongodbAllPods(envComponent)
|
|
64
63
|
).map(async (podName) => ({
|
|
65
64
|
podName,
|
|
66
65
|
componentName: podName.replace(/-mongodb-replicaset-[0-9]+/, ""),
|
|
@@ -70,8 +69,10 @@ export const getMongoDbPodsWithReplInfo = async (env: Env) => {
|
|
|
70
69
|
).sort((podA, podB) => (podA.isMaster ? (podB.isMaster ? 0 : -1) : 1));
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
export const getProjectMongodbAllPodsSortedWithLabel = async (
|
|
74
|
-
|
|
72
|
+
export const getProjectMongodbAllPodsSortedWithLabel = async (
|
|
73
|
+
envComponent: string
|
|
74
|
+
) => {
|
|
75
|
+
const pods = await getMongoDbPodsWithReplInfo(envComponent);
|
|
75
76
|
const maxComponentNameLength = Math.max(
|
|
76
77
|
...pods.map((c) => c.componentName.length)
|
|
77
78
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
1
2
|
import { spawn } from "child-process-promise";
|
|
2
3
|
import { writeFile } from "fs-extra";
|
|
3
4
|
import { withFile } from "tmp-promise";
|
|
@@ -8,17 +9,19 @@ import {
|
|
|
8
9
|
} from "../../../../config/constants";
|
|
9
10
|
import {
|
|
10
11
|
getEnvComponentChoices,
|
|
12
|
+
getEnvVars,
|
|
13
|
+
getPipelineContextByChoice,
|
|
11
14
|
getProjectConfig,
|
|
15
|
+
parseChoice,
|
|
12
16
|
} from "../../../../config/getProjectConfig";
|
|
13
17
|
import { readPass } from "../../../../utils/passwordstore";
|
|
14
|
-
import { getAllEnvVars, getProjectValues } from "../../../../utils/projects";
|
|
15
18
|
|
|
16
19
|
export default (vorpal: Vorpal) =>
|
|
17
20
|
vorpal
|
|
18
|
-
.command("project-cloud-sql-proxy <
|
|
21
|
+
.command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
|
|
19
22
|
.autocomplete(getEnvComponentChoices())
|
|
20
|
-
.action(async function ({
|
|
21
|
-
const
|
|
23
|
+
.action(async function ({ envComponent }) {
|
|
24
|
+
const { env } = parseChoice(envComponent);
|
|
22
25
|
|
|
23
26
|
const config = getProjectConfig();
|
|
24
27
|
// skynet-164509:europe-west6:pvl-cyclomania-review=tcp:5432
|
|
@@ -30,14 +33,18 @@ export default (vorpal: Vorpal) =>
|
|
|
30
33
|
message: "Local port: ",
|
|
31
34
|
});
|
|
32
35
|
|
|
33
|
-
const POSTGRESQL_PASSWORD = (await
|
|
36
|
+
const POSTGRESQL_PASSWORD = (await getEnvVars(this, envComponent))
|
|
34
37
|
?.POSTGRESQL_PASSWORD;
|
|
35
38
|
|
|
36
|
-
const
|
|
37
|
-
|
|
39
|
+
const context = await getPipelineContextByChoice(envComponent);
|
|
40
|
+
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
41
|
+
throw new Error("currently only supported for kubernetes deployment");
|
|
42
|
+
}
|
|
38
43
|
this.log(`postgres-PW: ${POSTGRESQL_PASSWORD}`);
|
|
39
44
|
this.log("");
|
|
40
45
|
|
|
46
|
+
const values = context.componentConfig.deploy.values;
|
|
47
|
+
|
|
41
48
|
const projectId = values?.cloudsql?.projectId || GOOGLE_PROJECT;
|
|
42
49
|
|
|
43
50
|
const defaultInstanceId = `${config.customerName}-${config.appName}-${env}`;
|