@catladder/cli 0.0.0-fix-migrate-string-cmd-508a469f → 0.0.0-fix-values-as-files-73f39da5
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/README.md +2 -1
- package/dist/apps/cli/commands/general/index.js +17 -9
- package/dist/apps/cli/commands/general/index.js.map +1 -1
- package/dist/apps/cli/commands/general/portForward.js +5 -6
- package/dist/apps/cli/commands/general/portForward.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +27 -19
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +175 -110
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js +4 -3
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
- package/dist/apps/cli/commands/project/{commandInitGitlab.d.ts → commandInitProject.old.d.ts} +0 -0
- package/dist/apps/cli/commands/project/{commandInitProject.js → commandInitProject.old.js} +1 -1
- package/dist/apps/cli/commands/project/commandInitProject.old.js.map +1 -0
- package/dist/apps/cli/commands/project/{commandInitProject.d.ts → commandSetup.d.ts} +0 -0
- package/dist/apps/cli/commands/project/{commandReloadConfig.js → commandSetup.js} +4 -8
- package/dist/apps/cli/commands/project/commandSetup.js.map +1 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js +2 -2
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
- package/dist/apps/cli/commands/project/index.js +3 -6
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/index.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/index.js +103 -0
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +115 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js +74 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +132 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js +1 -1
- package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +6 -8
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/apps/cli/config/writeConfig.js +1 -1
- package/dist/apps/cli/config/writeConfig.js.map +1 -1
- package/dist/apps/cli/verify/migration/fromv2.js +8 -6
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +8 -5
- package/dist/config/getProjectConfig.js +81 -36
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/k8sApi/index.d.ts +7 -5
- package/dist/k8sApi/index.js +23 -9
- package/dist/k8sApi/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cluster.js +0 -2
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/gitlab.d.ts +1 -0
- package/dist/utils/gitlab.js +17 -1
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/projects/index.js +7 -8
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +3 -3
- package/src/apps/cli/commands/general/index.ts +6 -7
- package/src/apps/cli/commands/general/portForward.ts +2 -1
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +24 -6
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +139 -128
- package/src/apps/cli/commands/project/commandDeletePods.ts +2 -1
- package/src/apps/cli/commands/project/{commandInitProject.ts → commandInitProject.old.ts} +0 -0
- package/src/apps/cli/commands/project/commandSetup.ts +12 -0
- package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -3
- package/src/apps/cli/commands/project/index.ts +4 -6
- package/src/apps/cli/commands/project/setup/index.ts +42 -0
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +72 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +37 -0
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +112 -0
- package/src/apps/cli/commands/project/utils/autocompletions.ts +2 -2
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +2 -1
- package/src/apps/cli/config/writeConfig.ts +1 -1
- package/src/apps/cli/verify/migration/fromv2.ts +4 -2
- package/src/config/getProjectConfig.ts +74 -34
- package/src/k8sApi/index.ts +20 -8
- package/src/utils/cluster.ts +0 -2
- package/src/utils/gitlab.ts +11 -0
- package/src/utils/projects/index.ts +3 -1
- package/dist/apps/cli/commands/project/commandInitGitlab.js +0 -136
- package/dist/apps/cli/commands/project/commandInitGitlab.js.map +0 -1
- package/dist/apps/cli/commands/project/commandInitProject.js.map +0 -1
- package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +0 -3
- package/dist/apps/cli/commands/project/commandReloadConfig.js.map +0 -1
- package/dist/utils/formatEnvVars.d.ts +0 -2
- package/dist/utils/formatEnvVars.js +0 -10
- package/dist/utils/formatEnvVars.js.map +0 -1
- package/src/apps/cli/commands/project/commandInitGitlab.ts +0 -248
- package/src/apps/cli/commands/project/commandReloadConfig.ts +0 -12
- package/src/utils/formatEnvVars.ts +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ } from "zx";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { getProjectConfig, parseChoice } from "../../config/getProjectConfig";
|
|
4
|
-
import
|
|
4
|
+
import { getk8sApi } from "../../k8sApi";
|
|
5
5
|
import { readFileOrError } from "../files";
|
|
6
6
|
|
|
7
7
|
export const getGitRoot = async (): Promise<string> => {
|
|
@@ -32,6 +32,7 @@ export const getProjectNamespace = async (envComponent: string) => {
|
|
|
32
32
|
|
|
33
33
|
export const getProjectPods = async (envComponent: string) => {
|
|
34
34
|
const namespace = await getProjectNamespace(envComponent);
|
|
35
|
+
const k8sApi = getk8sApi();
|
|
35
36
|
const res = await k8sApi.listNamespacedPod(namespace);
|
|
36
37
|
|
|
37
38
|
return res.body.items;
|
|
@@ -39,6 +40,7 @@ export const getProjectPods = async (envComponent: string) => {
|
|
|
39
40
|
|
|
40
41
|
export const getProjectPvcs = async (envComponent: string) => {
|
|
41
42
|
const namespace = await getProjectNamespace(envComponent);
|
|
43
|
+
const k8sApi = getk8sApi();
|
|
42
44
|
const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
|
|
43
45
|
|
|
44
46
|
return res.body.items;
|
|
@@ -1,136 +0,0 @@
|
|
|
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
|
-
};
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
-
function step(op) {
|
|
20
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (_) try {
|
|
22
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
-
switch (op[0]) {
|
|
25
|
-
case 0: case 1: t = op; break;
|
|
26
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
-
default:
|
|
30
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
-
if (t[2]) _.ops.pop();
|
|
35
|
-
_.trys.pop(); continue;
|
|
36
|
-
}
|
|
37
|
-
op = body.call(thisArg, _);
|
|
38
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
-
};
|
|
45
|
-
exports.__esModule = true;
|
|
46
|
-
var pipeline_1 = require("@catladder/pipeline");
|
|
47
|
-
var zx_1 = require("zx");
|
|
48
|
-
var getProjectConfig_1 = require("../../../../config/getProjectConfig");
|
|
49
|
-
var cluster_1 = require("../../../../utils/cluster");
|
|
50
|
-
var gitlab_1 = require("../../../../utils/gitlab");
|
|
51
|
-
var ensureNamespace_1 = __importDefault(require("./utils/ensureNamespace"));
|
|
52
|
-
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
return [2 /*return*/, vorpal
|
|
55
|
-
.command("project-init-gitlab", "Initializes the gitlab repo, e.g. connects the cluster to it")
|
|
56
|
-
.action(function () {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
var allContext, _i, allContext_1, context, deployConfig, fullName, namespace, serviceAccountName, KUBE_URL, e_1, tokenName, KUBE_CA_PEM, KUBE_TOKEN, vars;
|
|
59
|
-
return __generator(this, function (_a) {
|
|
60
|
-
switch (_a.label) {
|
|
61
|
-
case 0: return [4 /*yield*/, (0, getProjectConfig_1.getAllPipelineContexts)()];
|
|
62
|
-
case 1:
|
|
63
|
-
allContext = _a.sent();
|
|
64
|
-
_i = 0, allContext_1 = allContext;
|
|
65
|
-
_a.label = 2;
|
|
66
|
-
case 2:
|
|
67
|
-
if (!(_i < allContext_1.length)) return [3 /*break*/, 19];
|
|
68
|
-
context = allContext_1[_i];
|
|
69
|
-
deployConfig = context.componentConfig.deploy;
|
|
70
|
-
if (!(0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) return [3 /*break*/, 18];
|
|
71
|
-
fullName = (0, pipeline_1.getFullKubernetesClusterName)(deployConfig.cluster);
|
|
72
|
-
this.log("connecting ".concat(context.environment.shortName, ":").concat(context.componentName, " ").concat(fullName));
|
|
73
|
-
return [4 /*yield*/, (0, cluster_1.connectToCluster)(fullName)];
|
|
74
|
-
case 3:
|
|
75
|
-
_a.sent();
|
|
76
|
-
return [4 /*yield*/, (0, ensureNamespace_1["default"])(context)];
|
|
77
|
-
case 4:
|
|
78
|
-
namespace = _a.sent();
|
|
79
|
-
serviceAccountName = "cl-".concat(context.componentName, "-deploy");
|
|
80
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'"], ["TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'"]))).then(function (s) { return s.stdout.trim(); })];
|
|
81
|
-
case 5:
|
|
82
|
-
KUBE_URL = _a.sent();
|
|
83
|
-
_a.label = 6;
|
|
84
|
-
case 6:
|
|
85
|
-
_a.trys.push([6, 10, , 11]);
|
|
86
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["kubectl delete serviceaccount --namespace ", " ", ""], ["kubectl delete serviceaccount --namespace ", " ", ""])), namespace, serviceAccountName)];
|
|
87
|
-
case 7:
|
|
88
|
-
_a.sent();
|
|
89
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["kubectl delete rolebinding --namespace ", " ", ""], ["kubectl delete rolebinding --namespace ", " ", ""])), namespace, serviceAccountName)];
|
|
90
|
-
case 8:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["kubectl delete role --namespace ", " ", ""], ["kubectl delete role --namespace ", " ", ""])), namespace, serviceAccountName)];
|
|
93
|
-
case 9:
|
|
94
|
-
_a.sent();
|
|
95
|
-
return [3 /*break*/, 11];
|
|
96
|
-
case 10:
|
|
97
|
-
e_1 = _a.sent();
|
|
98
|
-
return [3 /*break*/, 11];
|
|
99
|
-
case 11: return [4 /*yield*/, (0, zx_1.$)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["kubectl create serviceaccount --namespace ", " ", ""], ["kubectl create serviceaccount --namespace ", " ", ""])), namespace, serviceAccountName)];
|
|
100
|
-
case 12:
|
|
101
|
-
_a.sent();
|
|
102
|
-
// upsert role in the ns
|
|
103
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["cat <<EOF | kubectl apply -f -\nkind: Role\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n namespace: ", "\n name: ", "\nrules:\n- apiGroups: [\"\", \"extensions\", \"apps\", \"networking.k8s.io\", \"batch\"]\n resources: [\"deployments\", \"replicasets\", \"pods\", \"secrets\", \"configmaps\", \"services\", \"ingresses\", \"serviceaccounts\", \"jobs\", \"cronjobs\"]\n verbs: [\"get\", \"list\", \"watch\", \"create\", \"update\", \"patch\", \"delete\"] # You can also use [\"*\"]\n---\nkind: RoleBinding\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n name: ", "\n namespace: ", "\nsubjects:\n - kind: ServiceAccount\n name: ", "\n namespace: ", "\nroleRef:\n kind: Role\n name: ", "\n apiGroup: rbac.authorization.k8s.io\nEOF\n "], ["cat <<EOF | kubectl apply -f -\nkind: Role\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n namespace: ", "\n name: ", "\nrules:\n- apiGroups: [\"\", \"extensions\", \"apps\", \"networking.k8s.io\", \"batch\"]\n resources: [\"deployments\", \"replicasets\", \"pods\", \"secrets\", \"configmaps\", \"services\", \"ingresses\", \"serviceaccounts\", \"jobs\", \"cronjobs\"]\n verbs: [\"get\", \"list\", \"watch\", \"create\", \"update\", \"patch\", \"delete\"] # You can also use [\"*\"]\n---\nkind: RoleBinding\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n name: ", "\n namespace: ", "\nsubjects:\n - kind: ServiceAccount\n name: ", "\n namespace: ", "\nroleRef:\n kind: Role\n name: ", "\n apiGroup: rbac.authorization.k8s.io\nEOF\n "])), namespace, serviceAccountName, serviceAccountName, namespace, serviceAccountName, namespace, serviceAccountName)];
|
|
104
|
-
case 13:
|
|
105
|
-
// upsert role in the ns
|
|
106
|
-
_a.sent();
|
|
107
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["kubectl get serviceaccount --namespace ", " ", " -o jsonpath='{.secrets[0].name}'"], ["kubectl get serviceaccount --namespace ", " ", " -o jsonpath='{.secrets[0].name}'"])), namespace, serviceAccountName)];
|
|
108
|
-
case 14:
|
|
109
|
-
tokenName = _a.sent();
|
|
110
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["kubectl get secret ", " --namespace ", " -o jsonpath=\"{['data']['ca\\.crt']}\""], ["kubectl get secret ", " --namespace ", " -o jsonpath=\"{['data']['ca\\\\.crt']}\""])), tokenName, namespace).then(function (c) { return c.stdout.trim(); })];
|
|
111
|
-
case 15:
|
|
112
|
-
KUBE_CA_PEM = _a.sent();
|
|
113
|
-
return [4 /*yield*/, (0, zx_1.$)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["kubectl get secret ", " --namespace ", " -o jsonpath=\"{['data']['token']}\" | base64 --decode"], ["kubectl get secret ", " --namespace ", " -o jsonpath=\"{['data']['token']}\" | base64 --decode"])), tokenName, namespace).then(function (c) { return c.stdout.trim(); })];
|
|
114
|
-
case 16:
|
|
115
|
-
KUBE_TOKEN = _a.sent();
|
|
116
|
-
vars = {
|
|
117
|
-
KUBE_TOKEN: KUBE_TOKEN,
|
|
118
|
-
KUBE_CA_PEM: KUBE_CA_PEM,
|
|
119
|
-
KUBE_URL: KUBE_URL
|
|
120
|
-
};
|
|
121
|
-
return [4 /*yield*/, (0, gitlab_1.upsertAllVariables)(this, vars, context.environment.shortName, context.componentName)];
|
|
122
|
-
case 17:
|
|
123
|
-
_a.sent();
|
|
124
|
-
_a.label = 18;
|
|
125
|
-
case 18:
|
|
126
|
-
_i++;
|
|
127
|
-
return [3 /*break*/, 2];
|
|
128
|
-
case 19: return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
})];
|
|
133
|
-
});
|
|
134
|
-
}); });
|
|
135
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
136
|
-
//# sourceMappingURL=commandInitGitlab.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandInitGitlab.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/project/commandInitGitlab.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAI6B;AAE7B,yBAAuB;AACvB,wEAA6E;AAC7E,qDAA6D;AAC7D,mDAA8D;AAC9D,4EAAsD;AAEtD,sBAAe,UAAO,MAAc;;QAClC,sBAAA,MAAM;iBACH,OAAO,CACN,qBAAqB,EACrB,8DAA8D,CAC/D;iBACA,MAAM,CAAC;;;;;oCACa,qBAAM,IAAA,yCAAsB,GAAE,EAAA;;gCAA3C,UAAU,GAAG,SAA8B;sCAEjB,EAAV,yBAAU;;;qCAAV,CAAA,wBAAU,CAAA;gCAArB,OAAO;gCACV,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC;qCAChD,IAAA,yBAAc,EAAC,YAAY,EAAE,YAAY,CAAC,EAA1C,yBAA0C;gCACtC,QAAQ,GAAG,IAAA,uCAA4B,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gCACpE,IAAI,CAAC,GAAG,CACN,qBAAc,OAAO,CAAC,WAAW,CAAC,SAAS,cAAI,OAAO,CAAC,aAAa,cAAI,QAAQ,CAAE,CACnF,CAAC;gCAEF,qBAAM,IAAA,0BAAgB,EAAC,QAAQ,CAAC,EAAA;;gCAAhC,SAAgC,CAAC;gCAEf,qBAAM,IAAA,4BAAe,EAAC,OAAO,CAAC,EAAA;;gCAA1C,SAAS,GAAG,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wC,IAAI,CACzG,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAf,CAAe,CACvB,EAAA;;gCAHG,WAAW,GACf,SAEC;gCAED,qBAAM,IAAA,MAAC,oKAAA,qBAAsB,EAAS,eAAgB,EAAS,wDAAsD,KAAxF,SAAS,EAAgB,SAAS,EAAuD,IAAI,CACxH,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAf,CAAe,CACvB,EAAA;;gCAHG,UAAU,GACd,SAEC;gCAEG,IAAI,GAAG;oCACX,UAAU,YAAA;oCACV,WAAW,aAAA;oCACX,QAAQ,UAAA;iCACT,CAAC;gCAEF,qBAAM,IAAA,2BAAkB,EACtB,IAAI,EACJ,IAAI,EACJ,OAAO,CAAC,WAAW,CAAC,SAAS,EAC7B,OAAO,CAAC,aAAa,CACtB,EAAA;;gCALD,SAKC,CAAC;;;gCAtFgB,IAAU,CAAA;;;;;;aAkOjC,CAAC,EAAA;;KAAA,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandInitProject.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/project/commandInitProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA+C;AAC/C,mCAA+B;AAC/B,iCAAqD;AACrD,8CAAwB;AAExB,uDAA6D;AAE7D,IAAM,YAAY,GAAG,UAAC,GAAW,IAAK,OAAA,IAAA,gBAAO,EAAC,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,EAAvB,CAAuB,CAAC;AAoB9D,IAAM,iBAAiB,GAAG;IACxB,WAAW,EAAE,YAAY;CAC1B,CAAC;AACF,4FAA4F;AAC5F,IAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC,IAAM,uBAAuB,GAAmB;IAC9C;QACE,QAAQ,EAAE,QAAQ;QAClB,OAA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,SAAe,CAAA;;;oDAAG,KAAA,OAAO,CAAA;;;oDADrD,UAAU,KAC2C;oDAC3D,qBAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,UAAU,CAAC,EAAA;;oDAArC,SAAqC,CAAC;;;;;iCACvC,CAAC,CAAC;gCAEH,qBAAM,IAAA,oBAAS,EAAC,YAAY,EAAE,IAAA,cAAI,EAAC,MAAM,CAAC,CAAC,EAAA;;gCAA3C,SAA2C,CAAC;gCAE5C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gCACb,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;gCACpC,IAAI,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;gCAClD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gCACb,IAAI,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;gCACrE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;oCAEY,qBAAM,IAAI,CAAC,MAAM,CAAC;oCAC3C,SAAO,EAAE,IAAI;oCACb,OAAO,EACL,mFAAmF;oCACrF,IAAI,EAAE,gBAAgB;oCACtB,IAAI,EAAE,SAAS;iCAChB,CAAC,EAAA;;gCANM,cAAc,GAAK,CAAA,SAMzB,CAAA,eANoB;qCAOlB,cAAc,EAAd,wBAAc;gCAChB,qBAAM,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAA;;gCAA5C,SAA4C,CAAC;;;;;;aAEhD,CAAC,EAAA;;KAAA,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandReloadConfig.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/project/commandReloadConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wEAAmE;AACnE,+DAA8D;AAE9D,sBAAe,UAAO,MAAc;;QAClC,sBAAA,MAAM;iBACH,OAAO,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;iBAEtD,MAAM,CAAC;;;;oCACN,qBAAM,IAAA,+BAAY,GAAE,EAAA;;gCAApB,SAAoB,CAAC;gCACrB,qBAAM,IAAA,qCAAiB,EAAC,MAAM,CAAC,EAAA;;gCAA/B,SAA+B,CAAC;;;;;aACjC,CAAC,EAAA;;KAAA,EAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
var lodash_1 = require("lodash");
|
|
4
|
-
exports["default"] = (function (envVars) {
|
|
5
|
-
if (envVars === void 0) { envVars = {}; }
|
|
6
|
-
return (0, lodash_1.mapValues)(envVars, function (value) {
|
|
7
|
-
return (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value);
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
//# sourceMappingURL=formatEnvVars.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatEnvVars.js","sourceRoot":"","sources":["../../src/utils/formatEnvVars.ts"],"names":[],"mappings":";;AAAA,iCAA6C;AAE7C,sBAAe,UAAC,OAAY;IAAZ,wBAAA,EAAA,YAAY;IAC1B,OAAO,IAAA,kBAAS,EAAC,OAAO,EAAE,UAAA,KAAK;QAC7B,OAAA,IAAA,iBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAG,KAAK,CAAE;IAApD,CAAoD,CACrD,CAAC;AACJ,CAAC,EAAC"}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getFullKubernetesClusterName,
|
|
3
|
-
isOfDeployType,
|
|
4
|
-
getKubernetesNamespace,
|
|
5
|
-
} from "@catladder/pipeline";
|
|
6
|
-
import Vorpal from "vorpal";
|
|
7
|
-
import { $ } from "zx";
|
|
8
|
-
import { getAllPipelineContexts } from "../../../../config/getProjectConfig";
|
|
9
|
-
import { connectToCluster } from "../../../../utils/cluster";
|
|
10
|
-
import { upsertAllVariables } from "../../../../utils/gitlab";
|
|
11
|
-
import ensureNamespace from "./utils/ensureNamespace";
|
|
12
|
-
|
|
13
|
-
export default async (vorpal: Vorpal) =>
|
|
14
|
-
vorpal
|
|
15
|
-
.command(
|
|
16
|
-
"project-init-gitlab",
|
|
17
|
-
"Initializes the gitlab repo, e.g. connects the cluster to it"
|
|
18
|
-
)
|
|
19
|
-
.action(async function () {
|
|
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
|
-
);
|
|
29
|
-
|
|
30
|
-
await connectToCluster(fullName);
|
|
31
|
-
|
|
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,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
await upsertAllVariables(
|
|
104
|
-
this,
|
|
105
|
-
vars,
|
|
106
|
-
context.environment.shortName,
|
|
107
|
-
context.componentName
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
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})`)
|
|
118
|
-
);
|
|
119
|
-
this.log("");
|
|
120
|
-
|
|
121
|
-
const missingClusters = Object.fromEntries(
|
|
122
|
-
Object.entries(configuredClusters).filter(
|
|
123
|
-
([c]) => !existingClusters.some((exist) => exist === c)
|
|
124
|
-
)
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
this.log("");
|
|
128
|
-
this.log("These clusters are not configured yet on gitlab:");
|
|
129
|
-
this.log("");
|
|
130
|
-
|
|
131
|
-
Object.entries(missingClusters).forEach(([fullname, config]) =>
|
|
132
|
-
this.log(` - ${config.cluster.name || "unknown"} (${fullname})`)
|
|
133
|
-
);
|
|
134
|
-
this.log("");
|
|
135
|
-
|
|
136
|
-
for (const [fullname, config] of Object.entries(missingClusters)) {
|
|
137
|
-
this.log(`${config.name} (${fullname})`);
|
|
138
|
-
this.log("");
|
|
139
|
-
const { shouldContinue } = await this.prompt({
|
|
140
|
-
type: "confirm",
|
|
141
|
-
name: "shouldContinue",
|
|
142
|
-
message: "Should I add the this cluster ? 🤔 ",
|
|
143
|
-
});
|
|
144
|
-
this.log("");
|
|
145
|
-
if (shouldContinue) {
|
|
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`;
|
|
153
|
-
const postResult = await doGitlabRequest(
|
|
154
|
-
this,
|
|
155
|
-
`projects/${projectId}/clusters/user`,
|
|
156
|
-
{
|
|
157
|
-
name: fullname,
|
|
158
|
-
managed: false,
|
|
159
|
-
environment_scope: "*",
|
|
160
|
-
platform_kubernetes_attributes: {
|
|
161
|
-
api_url,
|
|
162
|
-
ca_cert,
|
|
163
|
-
token,
|
|
164
|
-
namespace: await getProjectNamespace("prod"),
|
|
165
|
-
},
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
const { message } = postResult;
|
|
169
|
-
if (message) {
|
|
170
|
-
this.log(`Message from gitlab: ${message}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const variables = await doGitlabRequest(
|
|
176
|
-
this,
|
|
177
|
-
`projects/${projectId}/variables`
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
if (!variables.find((v: any) => v.key === "GL_TOKEN")) {
|
|
181
|
-
this.log(
|
|
182
|
-
"I need add a GL_TOKEN to the project, so that semantic release will work\n"
|
|
183
|
-
);
|
|
184
|
-
this.log(
|
|
185
|
-
"👉 Please please create a project access token in gitlab and copy its value into clipboard\n\n - name: something like 'semantic-release'\n - expires: leave empty\n - scopes: api, read_repository"
|
|
186
|
-
);
|
|
187
|
-
this.log("\n");
|
|
188
|
-
|
|
189
|
-
const { understood } = await this.prompt({
|
|
190
|
-
default: true,
|
|
191
|
-
message: "Understood and open gitlab now? 🤔",
|
|
192
|
-
name: "understood",
|
|
193
|
-
type: "confirm",
|
|
194
|
-
});
|
|
195
|
-
if (!understood) {
|
|
196
|
-
this.log("continuing anyway...");
|
|
197
|
-
}
|
|
198
|
-
open(`${projectWebUrl}/-/settings/access_tokens`);
|
|
199
|
-
|
|
200
|
-
this.log("\n");
|
|
201
|
-
|
|
202
|
-
this.log("Enter your copied token now: ");
|
|
203
|
-
|
|
204
|
-
this.log("\n");
|
|
205
|
-
const { GL_TOKEN } = await this.prompt({
|
|
206
|
-
type: "password",
|
|
207
|
-
name: "GL_TOKEN",
|
|
208
|
-
message: "Access Token: ",
|
|
209
|
-
});
|
|
210
|
-
await doGitlabRequest(this, `projects/${projectId}/variables`, {
|
|
211
|
-
key: "GL_TOKEN",
|
|
212
|
-
value: GL_TOKEN,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const deploy_tokens = await doGitlabRequest(
|
|
217
|
-
this,
|
|
218
|
-
`projects/${projectId}/deploy_tokens`
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
if (
|
|
222
|
-
!deploy_tokens.find(
|
|
223
|
-
(v: { name: string }) => v.name === "gitlab-deploy-token"
|
|
224
|
-
)
|
|
225
|
-
) {
|
|
226
|
-
this.log(
|
|
227
|
-
"I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project."
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
await doGitlabRequest(this, `projects/${projectId}/deploy_tokens`, {
|
|
231
|
-
id: projectId,
|
|
232
|
-
name: "gitlab-deploy-token",
|
|
233
|
-
scopes: ["read_registry"],
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
this.log("gitlab is ready! 🥂");
|
|
237
|
-
this.log("\n");
|
|
238
|
-
this.log("do not forget to make sure that:");
|
|
239
|
-
[
|
|
240
|
-
"you have __health route in place",
|
|
241
|
-
"lint and test are defined",
|
|
242
|
-
"eat your vegetables",
|
|
243
|
-
"be awesome 🤩",
|
|
244
|
-
].forEach((tip) => this.log(` - ${tip}`));
|
|
245
|
-
this.log("\n");
|
|
246
|
-
this.log("\n");
|
|
247
|
-
*/
|
|
248
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
2
|
-
import { reloadConfig } from "../../../../config/getProjectConfig";
|
|
3
|
-
import { showProjectBanner } from "./utils/showProjectBanner";
|
|
4
|
-
|
|
5
|
-
export default async (vorpal: Vorpal) =>
|
|
6
|
-
vorpal
|
|
7
|
-
.command("project-reload-config", "reloads the config")
|
|
8
|
-
|
|
9
|
-
.action(async function () {
|
|
10
|
-
await reloadConfig();
|
|
11
|
-
await showProjectBanner(vorpal);
|
|
12
|
-
});
|