@catladder/cli 1.1.2 → 1.3.2
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/general/index.js +0 -66
- package/dist/apps/cli/commands/general/index.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +15 -14
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCopyDB.js +3 -3
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -1
- package/dist/apps/cli/commands/project/commandInitGitlab.js +63 -172
- package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +7 -14
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.js +7 -2
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.js +21 -21
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/ensureCluster.js +1 -1
- package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +50 -36
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/apps/cli/commands/shared/index.d.ts +3 -2
- package/dist/apps/cli/commands/shared/index.js +7 -9
- package/dist/apps/cli/commands/shared/index.js.map +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +0 -30
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
- package/dist/apps/cli/verify/migration/fromv2.js +9 -3
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/catenv.js +2 -0
- package/dist/catenv.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/config/constants.d.ts +0 -1
- package/dist/config/constants.js +1 -2
- package/dist/config/constants.js.map +1 -1
- package/dist/config/getProjectConfig.js +5 -3
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/k8sApi/index.d.ts +1 -0
- package/dist/k8sApi/index.js +6 -2
- package/dist/k8sApi/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cluster.d.ts +2 -11
- package/dist/utils/cluster.js +13 -38
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/gitlab.js +6 -2
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/projects/index.js +10 -6
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +5 -4
- package/src/apps/cli/commands/general/index.ts +1 -39
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +4 -5
- package/src/apps/cli/commands/project/commandCopyDB.ts +4 -5
- package/src/apps/cli/commands/project/commandInitGitlab.ts +119 -74
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +10 -7
- package/src/apps/cli/commands/project/commandOpenGit.ts +2 -2
- package/src/apps/cli/commands/project/commandOpenLogs.ts +33 -4
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +7 -2
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +43 -19
- package/src/apps/cli/commands/shared/index.ts +19 -16
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +0 -19
- package/src/apps/cli/verify/migration/fromv2.ts +7 -2
- package/src/catenv.ts +2 -1
- package/src/cli.ts +2 -1
- package/src/config/constants.ts +0 -1
- package/src/config/getProjectConfig.ts +6 -4
- package/src/k8sApi/index.ts +5 -1
- package/src/utils/cluster.ts +8 -28
- package/src/utils/gitlab.ts +5 -0
- package/src/utils/projects/index.ts +2 -3
- package/dist/config/clusters.d.ts +0 -14
- package/dist/config/clusters.js +0 -72
- package/dist/config/clusters.js.map +0 -1
- package/src/config/clusters.ts +0 -45
package/dist/utils/cluster.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
export declare const getCurrentContext: () => Promise<
|
|
1
|
+
export declare const getCurrentContext: () => Promise<string>;
|
|
2
2
|
export declare const getCurrentConnectedClusterName: () => Promise<string>;
|
|
3
|
-
export declare const
|
|
4
|
-
name: string;
|
|
5
|
-
cluster: import("../config/clusters").Cluster;
|
|
6
|
-
};
|
|
7
|
-
export declare const getClusterByName: (name: string) => import("../config/clusters").Cluster;
|
|
8
|
-
export declare const getAllClusters: () => {
|
|
9
|
-
[clustername: string]: import("../config/clusters").Cluster;
|
|
10
|
-
};
|
|
11
|
-
export declare const getAllClusterNames: () => string[];
|
|
12
|
-
export declare const connectToCluster: (clusterName: string) => Promise<void>;
|
|
3
|
+
export declare const connectToCluster: (fullname: string) => Promise<void>;
|
package/dist/utils/cluster.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
2
6
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
7
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
8
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,66 +39,37 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
39
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
40
|
}
|
|
37
41
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
42
|
exports.__esModule = true;
|
|
42
|
-
exports.connectToCluster = exports.
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var clusters_1 = __importDefault(require("../config/clusters"));
|
|
43
|
+
exports.connectToCluster = exports.getCurrentConnectedClusterName = exports.getCurrentContext = void 0;
|
|
44
|
+
var zx_1 = require("zx");
|
|
45
|
+
var k8sApi_1 = require("../k8sApi");
|
|
46
46
|
var getCurrentContext = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
47
47
|
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, (0,
|
|
48
|
+
case 0: return [4 /*yield*/, (0, zx_1.$)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["kubectl config current-context"], ["kubectl config current-context"])))];
|
|
49
49
|
case 1: return [2 /*return*/, (_a.sent()).stdout.trim()];
|
|
50
50
|
}
|
|
51
51
|
}); }); };
|
|
52
52
|
exports.getCurrentContext = getCurrentContext;
|
|
53
53
|
var getCurrentConnectedClusterName = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
-
var currentContext;
|
|
55
54
|
return __generator(this, function (_a) {
|
|
56
55
|
switch (_a.label) {
|
|
57
56
|
case 0: return [4 /*yield*/, (0, exports.getCurrentContext)()];
|
|
58
|
-
case 1:
|
|
59
|
-
currentContext = _a.sent();
|
|
60
|
-
return [2 /*return*/, (0, lodash_1.findKey)(clusters_1["default"], { fullName: currentContext })];
|
|
57
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
61
58
|
}
|
|
62
59
|
});
|
|
63
60
|
}); };
|
|
64
61
|
exports.getCurrentConnectedClusterName = getCurrentConnectedClusterName;
|
|
65
|
-
var
|
|
66
|
-
var found = Object.entries((0, exports.getAllClusters)()).find(function (_a) {
|
|
67
|
-
var config = _a[1];
|
|
68
|
-
return config.fullName === fullName;
|
|
69
|
-
});
|
|
70
|
-
if (found) {
|
|
71
|
-
return { name: found[0], cluster: found[1] };
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
exports.getClusterByFullName = getClusterByFullName;
|
|
78
|
-
var getClusterByName = function (name) { return (0, exports.getAllClusters)()[name]; };
|
|
79
|
-
exports.getClusterByName = getClusterByName;
|
|
80
|
-
var getAllClusters = function () {
|
|
81
|
-
return clusters_1["default"];
|
|
82
|
-
};
|
|
83
|
-
exports.getAllClusters = getAllClusters;
|
|
84
|
-
var getAllClusterNames = function () { return Object.keys(clusters_1["default"]); };
|
|
85
|
-
exports.getAllClusterNames = getAllClusterNames;
|
|
86
|
-
var connectToCluster = function (clusterName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
var connect;
|
|
62
|
+
var connectToCluster = function (fullname) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
63
|
return __generator(this, function (_a) {
|
|
89
64
|
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
connect = (0, exports.getClusterByName)(clusterName).connect;
|
|
92
|
-
return [4 /*yield*/, connect()];
|
|
65
|
+
case 0: return [4 /*yield*/, (0, zx_1.$)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["kubectl config use-context ", ""], ["kubectl config use-context ", ""])), fullname)];
|
|
93
66
|
case 1:
|
|
94
67
|
_a.sent();
|
|
68
|
+
(0, k8sApi_1.reload)();
|
|
95
69
|
return [2 /*return*/];
|
|
96
70
|
}
|
|
97
71
|
});
|
|
98
72
|
}); };
|
|
99
73
|
exports.connectToCluster = connectToCluster;
|
|
74
|
+
var templateObject_1, templateObject_2;
|
|
100
75
|
//# sourceMappingURL=cluster.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/utils/cluster.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/utils/cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAuB;AACvB,oCAAmC;AAE5B,IAAM,iBAAiB,GAAG;;gBAC9B,yBAAM,MAAC,oGAAA,gCAAgC,MAAA;gBAAxC,sBAAA,CAAC,SAAuC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAA;;SAAA,CAAC;AAD7C,QAAA,iBAAiB,qBAC4B;AAEnD,IAAM,8BAA8B,GAAG;;;oBACrC,qBAAM,IAAA,yBAAiB,GAAE,EAAA;oBAAhC,sBAAO,SAAyB,EAAC;;;KAClC,CAAC;AAFW,QAAA,8BAA8B,kCAEzC;AAEK,IAAM,gBAAgB,GAAG,UAAO,QAAgB;;;oBACrD,yBAAM,MAAC,qGAAA,6BAA8B,EAAQ,EAAE,KAAV,QAAQ,GAAE;;gBAA/C,SAA+C,CAAC;gBAChD,IAAA,eAAM,GAAE,CAAC;;;;KACV,CAAC;AAHW,QAAA,gBAAgB,oBAG3B"}
|
package/dist/utils/gitlab.js
CHANGED
|
@@ -196,12 +196,15 @@ exports.getAllVariables = (0, memoizee_1["default"])(function (vorpal) { return
|
|
|
196
196
|
}
|
|
197
197
|
});
|
|
198
198
|
}); }, { promise: true });
|
|
199
|
+
var maskableRegex = new RegExp("^[a-zA-Z0-9_+=/@:.~-]{8,}$"); // SEE https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js#L20
|
|
200
|
+
var isMaskable = function (value) { return maskableRegex.test(value); };
|
|
199
201
|
var createVariable = function (vorpal, projectId, key, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
200
202
|
return __generator(this, function (_a) {
|
|
201
203
|
switch (_a.label) {
|
|
202
204
|
case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables"), {
|
|
203
205
|
key: key,
|
|
204
|
-
value: value
|
|
206
|
+
value: value,
|
|
207
|
+
masked: isMaskable(value)
|
|
205
208
|
})];
|
|
206
209
|
case 1: return [2 /*return*/, _a.sent()];
|
|
207
210
|
}
|
|
@@ -211,7 +214,8 @@ var updateVariable = function (vorpal, projectId, key, value) { return __awaiter
|
|
|
211
214
|
return __generator(this, function (_a) {
|
|
212
215
|
switch (_a.label) {
|
|
213
216
|
case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables/").concat(key), {
|
|
214
|
-
value: value
|
|
217
|
+
value: value,
|
|
218
|
+
masked: isMaskable(value)
|
|
215
219
|
}, true)];
|
|
216
220
|
case 1: return [2 /*return*/, _a.sent()];
|
|
217
221
|
}
|
package/dist/utils/gitlab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.js","sourceRoot":"","sources":["../../src/utils/gitlab.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,gDAAuD;AACvD,iCAAkC;AAClC,sDAAgC;AAChC,0DAA+B;AAC/B,8CAAwB;AAExB,6CAA4E;AAE5E,IAAM,SAAS,GAAG,8BAA8B,CAAC;AAE1C,IAAM,cAAc,GAAG;;gBAAY,qBAAM,IAAA,2BAAa,EAAC,SAAS,CAAC,EAAA;gBAA9B,sBAAA,SAA8B,EAAA;;SAAA,CAAC;AAA5D,QAAA,cAAc,kBAA8C;AAClE,IAAM,gBAAgB,GAAG,UAAO,MAAuB;;;;;gBAC5D,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACf,MAAM,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;gBAC5E,MAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;gBAChE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACf,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBACtD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACY,qBAAM,MAAM,CAAC,MAAM,CAAC;wBAC7C,SAAO,EAAE,IAAI;wBACb,OAAO,EAAE,IAAI;wBACb,IAAI,EAAE,gBAAgB;wBACtB,IAAI,EAAE,QA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c,CAAC,EAAA;;gBAAzD,SAAyD,CAAC;;;;gBAE1D,qBAAM,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,cAAc,CAAC,EAAA;;gBAAzD,SAAyD,CAAC;;;gBAE1D,uBAAe,CAAC,KAAK,EAAE,CAAC;;;gBARD,IAA+B,CAAA;;;;;KAW3D,CAAC;AAnBW,QAAA,kBAAkB,sBAmB7B"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
2
6
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
7
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
8
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -40,17 +44,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
44
|
};
|
|
41
45
|
exports.__esModule = true;
|
|
42
46
|
exports.getProjectPodNames = exports.getProjectPvcs = exports.getProjectPods = exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
|
|
43
|
-
var
|
|
47
|
+
var zx_1 = require("zx");
|
|
44
48
|
var path_1 = require("path");
|
|
45
49
|
var getProjectConfig_1 = require("../../config/getProjectConfig");
|
|
46
50
|
var k8sApi_1 = __importDefault(require("../../k8sApi"));
|
|
47
51
|
var files_1 = require("../files");
|
|
48
52
|
var getGitRoot = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
case
|
|
53
|
-
case 1: return [2 /*return*/, (_a = (_b.sent()).stdout) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, (0, zx_1.$)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["git rev-parse --show-toplevel"], ["git rev-parse --show-toplevel"])))];
|
|
56
|
+
case 1: return [2 /*return*/, (_a.sent()).stdout.trim()];
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
59
|
}); };
|
|
@@ -147,4 +150,5 @@ var getProjectPodNames = function (envComponent) { return __awaiter(void 0, void
|
|
|
147
150
|
});
|
|
148
151
|
}); };
|
|
149
152
|
exports.getProjectPodNames = getProjectPodNames;
|
|
153
|
+
var templateObject_1;
|
|
150
154
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAuB;AACvB,6BAA4B;AAC5B,kEAA8E;AAC9E,wDAAkC;AAClC,kCAA2C;AAEpC,IAAM,UAAU,GAAG;;;oBAChB,yBAAM,MAAC,mGAAA,+BAA+B,MAAA;oBAA9C,sBAAO,CAAC,SAAsC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAC;;;KAC/D,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,IAAM,mBAAmB,GAAG;;;;oBACjB,qBAAM,IAAA,kBAAU,GAAE,EAAA;;gBAA5B,OAAO,GAAG,SAAkB;gBAClC,sBAAO,IAAA,WAAI,EAAC,OAAO,EAAE,gBAAgB,CAAC,EAAC;;;KACxC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B;AAEK,IAAM,oBAAoB,GAAG;;;YAClC,KAAA,uBAAe,CAAA;YAAC,qBAAM,IAAA,2BAAmB,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CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,IAAM,kBAAkB,GAAG,UAAO,YAAoB;;;;oBAC9C,qBAAM,IAAA,sBAAc,EAAC,YAAY,CAAC,EAAA;;gBAAzC,IAAI,GAAG,SAAkC;gBAC/C,sBAAO,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAf,CAAe,CAAC,EAAC;;;KACzC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B"}
|
package/package.json
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"catladder": "./bin/catladder"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@catladder/pipeline": "1.
|
|
20
|
-
"@kubernetes/client-node": "^0.16.
|
|
19
|
+
"@catladder/pipeline": "1.3.2",
|
|
20
|
+
"@kubernetes/client-node": "^0.16.2",
|
|
21
21
|
"child-process-promise": "^2.2.1",
|
|
22
22
|
"command-exists-promise": "^2.0.2",
|
|
23
23
|
"common-tags": "^1.8.0",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"open": "^8.4.0",
|
|
32
32
|
"tmp-promise": "^2.0.2",
|
|
33
33
|
"update-notifier": "^2.5.0",
|
|
34
|
-
"vorpal": "^1.12.0"
|
|
34
|
+
"vorpal": "^1.12.0",
|
|
35
|
+
"zx": "^4.3.0"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=12.0.0"
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"eslint": "^8.7.0",
|
|
54
55
|
"typescript": "^4.5.4"
|
|
55
56
|
},
|
|
56
|
-
"version": "1.
|
|
57
|
+
"version": "1.3.2"
|
|
57
58
|
}
|
|
@@ -2,8 +2,6 @@ import memoizee from "memoizee";
|
|
|
2
2
|
import Vorpal from "vorpal";
|
|
3
3
|
import k8sApi from "../../../../k8sApi";
|
|
4
4
|
import {
|
|
5
|
-
connectToCluster,
|
|
6
|
-
getAllClusterNames,
|
|
7
5
|
getCurrentConnectedClusterName,
|
|
8
6
|
getCurrentContext,
|
|
9
7
|
} from "../../../../utils/cluster";
|
|
@@ -15,10 +13,7 @@ import {
|
|
|
15
13
|
} from "../../../../utils/portForward";
|
|
16
14
|
import { getShell } from "../../../../utils/shell";
|
|
17
15
|
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
18
|
-
import {
|
|
19
|
-
openGoogleCloudKubernetesDashboard,
|
|
20
|
-
openGoogleCloudLogs,
|
|
21
|
-
} from "../shared";
|
|
16
|
+
import { openGoogleCloudLogs } from "../shared";
|
|
22
17
|
import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
|
|
23
18
|
import portForward from "./portForward";
|
|
24
19
|
|
|
@@ -35,13 +30,6 @@ export const getAllNamespacesNames = async () => {
|
|
|
35
30
|
return namespaces.map((n) => n.metadata.name);
|
|
36
31
|
};
|
|
37
32
|
export default async (vorpal: Vorpal) => {
|
|
38
|
-
vorpal
|
|
39
|
-
.command("connect-cluster <clustername>")
|
|
40
|
-
.autocomplete(getAllClusterNames())
|
|
41
|
-
.action(async function ({ clustername }) {
|
|
42
|
-
this.log(`connecting to ${clustername}`);
|
|
43
|
-
await connectToCluster(clustername);
|
|
44
|
-
});
|
|
45
33
|
vorpal.command("current-context").action(async function () {
|
|
46
34
|
this.log(await getCurrentContext());
|
|
47
35
|
});
|
|
@@ -82,32 +70,6 @@ export default async (vorpal: Vorpal) => {
|
|
|
82
70
|
stopPortForward(name.trim());
|
|
83
71
|
});
|
|
84
72
|
|
|
85
|
-
vorpal
|
|
86
|
-
.command("open-dashboard <namespace>", "open kubernetes dashboard")
|
|
87
|
-
.autocomplete(namespaceAutoCompletion)
|
|
88
|
-
.action(async function ({ namespace }) {
|
|
89
|
-
const clustername = await getCurrentConnectedClusterName();
|
|
90
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
91
|
-
|
|
92
|
-
await openGoogleCloudKubernetesDashboard(
|
|
93
|
-
authGoogleNumber,
|
|
94
|
-
clustername,
|
|
95
|
-
namespace
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
vorpal
|
|
99
|
-
.command(
|
|
100
|
-
"open-logs <namespace>",
|
|
101
|
-
"open google cloud logs (stackdriver stuff)"
|
|
102
|
-
)
|
|
103
|
-
.autocomplete(namespaceAutoCompletion)
|
|
104
|
-
.action(async function ({ namespace }) {
|
|
105
|
-
const clustername = await getCurrentConnectedClusterName();
|
|
106
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
107
|
-
|
|
108
|
-
await openGoogleCloudLogs(authGoogleNumber, clustername, namespace);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
73
|
vorpal
|
|
112
74
|
.command("get-shell <namespace>", "get a shell to a pod in the environment")
|
|
113
75
|
.autocomplete(namespaceAutoCompletion)
|
|
@@ -3,10 +3,7 @@ import { spawn } from "child-process-promise";
|
|
|
3
3
|
import { writeFile } from "fs-extra";
|
|
4
4
|
import { withFile } from "tmp-promise";
|
|
5
5
|
import Vorpal from "vorpal";
|
|
6
|
-
import {
|
|
7
|
-
GOOGLE_CLOUD_SQL_PASS_PATH,
|
|
8
|
-
GOOGLE_PROJECT,
|
|
9
|
-
} from "../../../../config/constants";
|
|
6
|
+
import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
|
|
10
7
|
import {
|
|
11
8
|
getEnvVars,
|
|
12
9
|
getPipelineContextByChoice,
|
|
@@ -45,7 +42,9 @@ export default async (vorpal: Vorpal) =>
|
|
|
45
42
|
|
|
46
43
|
const values = context.componentConfig.deploy.values;
|
|
47
44
|
|
|
48
|
-
const projectId =
|
|
45
|
+
const projectId =
|
|
46
|
+
values?.cloudsql?.projectId ||
|
|
47
|
+
context.componentConfig.deploy.cluster?.projectId;
|
|
49
48
|
|
|
50
49
|
const defaultInstanceId = `${config.customerName}-${config.appName}-${env}`;
|
|
51
50
|
const instanceId = values?.cloudsql?.instanceId || defaultInstanceId;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { spawn } from "child-process-promise";
|
|
2
2
|
import Vorpal from "vorpal";
|
|
3
|
-
import {
|
|
4
|
-
GOOGLE_CLOUD_SQL_PASS_PATH,
|
|
5
|
-
GOOGLE_PROJECT,
|
|
6
|
-
} from "../../../../config/constants";
|
|
3
|
+
import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
|
|
7
4
|
import {
|
|
8
5
|
getEnvVars,
|
|
9
6
|
getProjectConfig,
|
|
@@ -34,6 +31,8 @@ export default async (vorpal: Vorpal) =>
|
|
|
34
31
|
return;
|
|
35
32
|
}
|
|
36
33
|
|
|
34
|
+
// TODO: reimpleent with new config
|
|
35
|
+
throw new Error("needs reimplementation with new config");
|
|
37
36
|
const GOOGLE_CLOUD_SQL_REGION = "europe-west6"; // currently hardcoded
|
|
38
37
|
const { POSTGRESQL_PASSWORD } = await getEnvVars(
|
|
39
38
|
this,
|
|
@@ -43,7 +42,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
43
42
|
|
|
44
43
|
const LOCAL_PORT = 54321;
|
|
45
44
|
|
|
46
|
-
const instanceName = `${
|
|
45
|
+
const instanceName = `${"xxxxxx reimplement shoulld be project id"}:${GOOGLE_CLOUD_SQL_REGION}:${customerName}-${appName}-${env}=tcp:${LOCAL_PORT}`;
|
|
47
46
|
const cloudsqlCredentials = await readPass(GOOGLE_CLOUD_SQL_PASS_PATH);
|
|
48
47
|
|
|
49
48
|
const { POSTGRESQL_URL } = process.env;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
getFullKubernetesClusterName,
|
|
3
|
+
isOfDeployType,
|
|
4
|
+
getKubernetesNamespace,
|
|
5
|
+
} from "@catladder/pipeline";
|
|
3
6
|
import Vorpal from "vorpal";
|
|
7
|
+
import { $ } from "zx";
|
|
4
8
|
import { getAllPipelineContexts } from "../../../../config/getProjectConfig";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "../../../../utils/cluster";
|
|
9
|
-
import { doGitlabRequest, getProjectInfo } from "../../../../utils/gitlab";
|
|
10
|
-
import { readPass } from "../../../../utils/passwordstore";
|
|
11
|
-
import { getProjectNamespace } from "../../../../utils/projects";
|
|
9
|
+
import { connectToCluster } from "../../../../utils/cluster";
|
|
10
|
+
import { upsertAllVariables } from "../../../../utils/gitlab";
|
|
11
|
+
import ensureNamespace from "./utils/ensureNamespace";
|
|
12
12
|
|
|
13
13
|
export default async (vorpal: Vorpal) =>
|
|
14
14
|
vorpal
|
|
@@ -17,78 +17,124 @@ export default async (vorpal: Vorpal) =>
|
|
|
17
17
|
"Initializes the gitlab repo, e.g. connects the cluster to it"
|
|
18
18
|
)
|
|
19
19
|
.action(async function () {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const allContext = await getAllPipelineContexts();
|
|
21
|
+
|
|
22
|
+
for (const context of allContext) {
|
|
23
|
+
const deployConfig = context.componentConfig.deploy;
|
|
24
|
+
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
25
|
+
const fullName = getFullKubernetesClusterName(deployConfig.cluster);
|
|
26
|
+
this.log(
|
|
27
|
+
`connecting ${context.environment.shortName}:${context.componentName} ${fullName}`
|
|
28
|
+
);
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
(c: { name: string }) => {
|
|
30
|
-
const found = getClusterByFullName(c.name);
|
|
30
|
+
await connectToCluster(fullName);
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const namespace = await ensureNamespace(context);
|
|
33
|
+
|
|
34
|
+
//$.verbose = true;
|
|
35
|
+
|
|
36
|
+
// we name the service account and the role and the role binding with the same name
|
|
37
|
+
// we currently create one per component to better separate them
|
|
38
|
+
const serviceAccountName = `cl-${context.componentName}-deploy`;
|
|
39
|
+
const KUBE_URL =
|
|
40
|
+
await $`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`.then(
|
|
41
|
+
(s) => s.stdout.trim()
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// first upsert service acount in the ns
|
|
45
|
+
try {
|
|
46
|
+
await $`kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}`;
|
|
47
|
+
await $`kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}`;
|
|
48
|
+
await $`kubectl delete role --namespace ${namespace} ${serviceAccountName}`;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// ignore
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
await $`kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}`;
|
|
54
|
+
|
|
55
|
+
// upsert role in the ns
|
|
56
|
+
|
|
57
|
+
await $`cat <<EOF | kubectl apply -f -
|
|
58
|
+
kind: Role
|
|
59
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
60
|
+
metadata:
|
|
61
|
+
namespace: ${namespace}
|
|
62
|
+
name: ${serviceAccountName}
|
|
63
|
+
rules:
|
|
64
|
+
- apiGroups: ["", "extensions", "apps", "networking.k8s.io", "batch"]
|
|
65
|
+
resources: ["deployments", "replicasets", "pods", "secrets", "configmaps", "services", "ingresses", "serviceaccounts", "jobs", "cronjobs"]
|
|
66
|
+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] # You can also use ["*"]
|
|
67
|
+
---
|
|
68
|
+
kind: RoleBinding
|
|
69
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
70
|
+
metadata:
|
|
71
|
+
name: ${serviceAccountName}
|
|
72
|
+
namespace: ${namespace}
|
|
73
|
+
subjects:
|
|
74
|
+
- kind: ServiceAccount
|
|
75
|
+
name: ${serviceAccountName}
|
|
76
|
+
namespace: ${namespace}
|
|
77
|
+
roleRef:
|
|
78
|
+
kind: Role
|
|
79
|
+
name: ${serviceAccountName}
|
|
80
|
+
apiGroup: rbac.authorization.k8s.io
|
|
81
|
+
EOF
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
// get token name
|
|
85
|
+
const tokenName =
|
|
86
|
+
await $`kubectl get serviceaccount --namespace ${namespace} ${serviceAccountName} -o jsonpath='{.secrets[0].name}'`;
|
|
87
|
+
|
|
88
|
+
const KUBE_CA_PEM =
|
|
89
|
+
await $`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"`.then(
|
|
90
|
+
(c) => c.stdout.trim()
|
|
91
|
+
);
|
|
92
|
+
const KUBE_TOKEN =
|
|
93
|
+
await $`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode`.then(
|
|
94
|
+
(c) => c.stdout.trim()
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const vars = {
|
|
98
|
+
KUBE_TOKEN,
|
|
99
|
+
KUBE_CA_PEM,
|
|
100
|
+
KUBE_URL,
|
|
35
101
|
};
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
102
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.log(` - ${cluster.name || "unknown"} (${cluster.fullName})`)
|
|
47
|
-
);
|
|
103
|
+
await upsertAllVariables(
|
|
104
|
+
this,
|
|
105
|
+
vars,
|
|
106
|
+
context.environment.shortName,
|
|
107
|
+
context.componentName
|
|
108
|
+
);
|
|
109
|
+
}
|
|
48
110
|
}
|
|
49
111
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const configuredClusterNames = allDeployments.reduce<string[]>(
|
|
57
|
-
(acc, c) => {
|
|
58
|
-
if (
|
|
59
|
-
isOfDeployType(c, "kubernetes") &&
|
|
60
|
-
!acc.includes(c.cluster || "production")
|
|
61
|
-
) {
|
|
62
|
-
return [...acc, c.cluster || "production"];
|
|
63
|
-
}
|
|
64
|
-
return acc;
|
|
65
|
-
},
|
|
66
|
-
[]
|
|
67
|
-
);
|
|
68
|
-
const configuredClusters = configuredClusterNames.map((c) => ({
|
|
69
|
-
name: c,
|
|
70
|
-
config: getClusterByName(c),
|
|
71
|
-
}));
|
|
72
|
-
configuredClusters.forEach((cluster) =>
|
|
73
|
-
this.log(` - ${cluster.name || "unknown"} (${cluster.config.fullName})`)
|
|
112
|
+
// there is a constraint, see https://git.panter.ch/catladder/catladder/-/issues/2#note_345677
|
|
113
|
+
// any two components have to use the same custer per env, so e.g. dev:api and dev:www cannot use two different namespaces
|
|
114
|
+
// in practise, that is often not an issue, but it might happen because the config allows it
|
|
115
|
+
/*
|
|
116
|
+
Object.entries(configuredClusters).forEach(([fullname, config]) =>
|
|
117
|
+
this.log(` - ${config.cluster.name || "unknown"} (${fullname})`)
|
|
74
118
|
);
|
|
75
119
|
this.log("");
|
|
76
120
|
|
|
77
|
-
const missingClusters =
|
|
78
|
-
(
|
|
121
|
+
const missingClusters = Object.fromEntries(
|
|
122
|
+
Object.entries(configuredClusters).filter(
|
|
123
|
+
([c]) => !existingClusters.some((exist) => exist === c)
|
|
124
|
+
)
|
|
79
125
|
);
|
|
80
126
|
|
|
81
127
|
this.log("");
|
|
82
128
|
this.log("These clusters are not configured yet on gitlab:");
|
|
83
129
|
this.log("");
|
|
84
130
|
|
|
85
|
-
missingClusters.forEach((
|
|
86
|
-
this.log(` - ${cluster.name || "unknown"} (${
|
|
131
|
+
Object.entries(missingClusters).forEach(([fullname, config]) =>
|
|
132
|
+
this.log(` - ${config.cluster.name || "unknown"} (${fullname})`)
|
|
87
133
|
);
|
|
88
134
|
this.log("");
|
|
89
135
|
|
|
90
|
-
for (const
|
|
91
|
-
this.log(`${
|
|
136
|
+
for (const [fullname, config] of Object.entries(missingClusters)) {
|
|
137
|
+
this.log(`${config.name} (${fullname})`);
|
|
92
138
|
this.log("");
|
|
93
139
|
const { shouldContinue } = await this.prompt({
|
|
94
140
|
type: "confirm",
|
|
@@ -97,22 +143,20 @@ export default async (vorpal: Vorpal) =>
|
|
|
97
143
|
});
|
|
98
144
|
this.log("");
|
|
99
145
|
if (shouldContinue) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const token = await readPass(passCredentials.token);
|
|
108
|
-
const ca_cert = await readPass(passCredentials.ca_cert);
|
|
109
|
-
|
|
146
|
+
await connectToCluster(fullname);
|
|
147
|
+
const { stdout: api_url } =
|
|
148
|
+
await $`kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`;
|
|
149
|
+
const { stdout: ca_cert } =
|
|
150
|
+
await $`kubectl get secret default-token-69xv4 -o jsonpath="{['data']['ca\.crt']}" | base64 --decode`;
|
|
151
|
+
const { stdout: token } =
|
|
152
|
+
await $`kubectl get secret default-token-69xv4 -o jsonpath="{['data']['token']}" | base64 --decode`;
|
|
110
153
|
const postResult = await doGitlabRequest(
|
|
111
154
|
this,
|
|
112
155
|
`projects/${projectId}/clusters/user`,
|
|
113
156
|
{
|
|
114
|
-
name:
|
|
157
|
+
name: fullname,
|
|
115
158
|
managed: false,
|
|
159
|
+
environment_scope: "*",
|
|
116
160
|
platform_kubernetes_attributes: {
|
|
117
161
|
api_url,
|
|
118
162
|
ca_cert,
|
|
@@ -200,4 +244,5 @@ export default async (vorpal: Vorpal) =>
|
|
|
200
244
|
].forEach((tip) => this.log(` - ${tip}`));
|
|
201
245
|
this.log("\n");
|
|
202
246
|
this.log("\n");
|
|
247
|
+
*/
|
|
203
248
|
});
|
|
@@ -3,11 +3,9 @@ import {
|
|
|
3
3
|
getPipelineContextByChoice,
|
|
4
4
|
parseChoice,
|
|
5
5
|
} from "../../../../config/getProjectConfig";
|
|
6
|
-
import { getCurrentConnectedClusterName } from "../../../../utils/cluster";
|
|
7
6
|
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
8
7
|
import { openGoogleCloudKubernetesDashboard } from "../shared";
|
|
9
8
|
import { envAndComponents } from "./utils/autocompletions";
|
|
10
|
-
import ensureCluster from "./utils/ensureCluster";
|
|
11
9
|
export default async (vorpal: Vorpal) =>
|
|
12
10
|
vorpal
|
|
13
11
|
.command(
|
|
@@ -30,16 +28,21 @@ export default async (vorpal: Vorpal) =>
|
|
|
30
28
|
"only kubernetes deployments are supported at the moment"
|
|
31
29
|
);
|
|
32
30
|
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
!componentConfig.deploy.cluster ||
|
|
34
|
+
componentConfig.deploy.cluster.type !== "gcloud"
|
|
35
|
+
) {
|
|
36
|
+
throw new Error("no gcloud custer configured");
|
|
37
|
+
}
|
|
33
38
|
// currently only supports kubernetes
|
|
34
39
|
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
35
|
-
await ensureCluster.call(this, envComponent); // TODO: implement
|
|
36
|
-
const clustername = await getCurrentConnectedClusterName();
|
|
37
40
|
|
|
38
41
|
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
39
42
|
|
|
40
43
|
openGoogleCloudKubernetesDashboard(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
componentConfig.deploy.cluster,
|
|
45
|
+
namespace,
|
|
46
|
+
authGoogleNumber
|
|
44
47
|
);
|
|
45
48
|
});
|