@catladder/cli 1.89.3 → 1.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +12 -18
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +15 -4
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupContext.js +3 -10
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.js +3 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +5 -14
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +16 -2
- package/src/apps/cli/commands/project/setup/setupContext.ts +2 -5
- package/src/apps/cli/verify/migration/migrateSecrets.ts +6 -1
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.d.ts +0 -3
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js +0 -56
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +0 -1
- package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +0 -22
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=12.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@catladder/pipeline": "1.
|
|
27
|
+
"@catladder/pipeline": "1.91.0",
|
|
28
28
|
"@kubernetes/client-node": "^0.16.2",
|
|
29
29
|
"@tsconfig/node14": "^1.0.1",
|
|
30
30
|
"@types/common-tags": "^1.8.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"typescript": "^4.5.4",
|
|
58
58
|
"vorpal": "^1.12.0"
|
|
59
59
|
},
|
|
60
|
-
"version": "1.
|
|
60
|
+
"version": "1.91.0"
|
|
61
61
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { createKubernetesCloudsqlBaseValues } from "@catladder/pipeline";
|
|
2
3
|
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
4
|
import { spawn } from "child-process-promise";
|
|
4
5
|
import { writeFile } from "fs-extra";
|
|
@@ -103,24 +104,14 @@ const getProxyInfoForKubernetes = async (
|
|
|
103
104
|
context.environment.shortName,
|
|
104
105
|
context.componentName
|
|
105
106
|
);
|
|
107
|
+
// bit hacky, would be nicer if we would also declare this through env vars
|
|
108
|
+
const cloudSqlValues = createKubernetesCloudsqlBaseValues(context);
|
|
106
109
|
|
|
107
110
|
const DB_PASSWORD = envVars?.DB_PASSWORD || envVars?.POSTGRESQL_PASSWORD;
|
|
108
111
|
|
|
109
|
-
const DB_NAME =
|
|
112
|
+
const DB_NAME = cloudSqlValues.cloudsql.fullDbName;
|
|
110
113
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const projectId =
|
|
114
|
-
values?.cloudsql?.projectId ||
|
|
115
|
-
context.componentConfig.deploy.cluster?.projectId;
|
|
116
|
-
|
|
117
|
-
const defaultInstanceId = `${context.fullConfig.customerName}-${context.fullConfig.appName}-${context.environment.shortName}`;
|
|
118
|
-
const instanceId = values?.cloudsql?.instanceId || defaultInstanceId;
|
|
119
|
-
|
|
120
|
-
const defaultRegion = "europe-west6"; // currently hardcoded
|
|
121
|
-
const region = values?.cloudsql?.region || defaultRegion;
|
|
122
|
-
|
|
123
|
-
const instanceName = `${projectId}:${region}:${instanceId}`;
|
|
114
|
+
const instanceName = cloudSqlValues.cloudsql.instanceConnectionName;
|
|
124
115
|
|
|
125
116
|
return {
|
|
126
117
|
instanceName,
|
|
@@ -45,12 +45,22 @@ const resolveJson = (v: Vars) =>
|
|
|
45
45
|
})
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
+
const getNonHiddenSecretEnvVarKeys = async (
|
|
49
|
+
env: string,
|
|
50
|
+
componentName: string
|
|
51
|
+
) => {
|
|
52
|
+
const { secretEnvVarKeys } = await getEnvironment(env, componentName);
|
|
53
|
+
return secretEnvVarKeys.filter((k) => !k.hidden).map((k) => k.key);
|
|
54
|
+
};
|
|
48
55
|
const getEnvVarsToEdit = async (
|
|
49
56
|
instance: CommandInstance,
|
|
50
57
|
env: string,
|
|
51
58
|
componentName: string
|
|
52
59
|
) => {
|
|
53
|
-
const
|
|
60
|
+
const secretEnvVarKeys = await getNonHiddenSecretEnvVarKeys(
|
|
61
|
+
env,
|
|
62
|
+
componentName
|
|
63
|
+
);
|
|
54
64
|
|
|
55
65
|
const allEnvVars = await getEnvVars(instance, env, componentName);
|
|
56
66
|
return Object.fromEntries(
|
|
@@ -107,7 +117,11 @@ const doItFor = async (
|
|
|
107
117
|
? Object.keys(valuesToEdit[componentName][env])
|
|
108
118
|
: [];
|
|
109
119
|
// check whether newValues have the exact number of keys
|
|
110
|
-
const
|
|
120
|
+
const secretEnvVarKeys = await getNonHiddenSecretEnvVarKeys(
|
|
121
|
+
env,
|
|
122
|
+
componentName
|
|
123
|
+
);
|
|
124
|
+
|
|
111
125
|
const extranous = difference(usedKeys, secretEnvVarKeys);
|
|
112
126
|
const missing = difference(secretEnvVarKeys, usedKeys);
|
|
113
127
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Context } from "@catladder/pipeline";
|
|
2
|
-
import { isOfDeployType
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
3
|
import type { CommandInstance } from "vorpal";
|
|
4
4
|
import { setupCloudRun } from "./setupCloudRun";
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import { setupKubernetes } from "./setupKubernetes";
|
|
7
7
|
|
|
8
8
|
export const setupContext = async (
|
|
@@ -25,9 +25,6 @@ export const setupContext = async (
|
|
|
25
25
|
if (isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
26
26
|
await setupCloudRun(instance, context);
|
|
27
27
|
}
|
|
28
|
-
if (hasKubernetesCloudSQL(context)) {
|
|
29
|
-
await setupCloudSQL(instance, context);
|
|
30
|
-
}
|
|
31
28
|
|
|
32
29
|
const deployConfig = context.componentConfig.deploy;
|
|
33
30
|
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
@@ -30,7 +30,12 @@ export const migrateSecrets = async (
|
|
|
30
30
|
);
|
|
31
31
|
await upsertAllVariables(
|
|
32
32
|
vorpal,
|
|
33
|
-
pick(
|
|
33
|
+
pick(
|
|
34
|
+
secrets,
|
|
35
|
+
environment.secretEnvVarKeys
|
|
36
|
+
.filter((k) => !k.hidden)
|
|
37
|
+
.map((k) => k.key)
|
|
38
|
+
),
|
|
34
39
|
newEnv,
|
|
35
40
|
componentName
|
|
36
41
|
);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
exports.setupCloudSQL = void 0;
|
|
40
|
-
var pipeline_1 = require("@catladder/pipeline");
|
|
41
|
-
var setupCloudSQL = function (instance, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
var config;
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
if (!(0, pipeline_1.hasKubernetesCloudSQL)(context)) {
|
|
45
|
-
throw new Error("cannot setup cloudsql, as it has none");
|
|
46
|
-
}
|
|
47
|
-
config = (0, pipeline_1.getKubernetesCloudSQLConfig)(context);
|
|
48
|
-
instance.log("");
|
|
49
|
-
instance.log("! make sure to provide cloudsqlProxyCredentials for the cloud sql service account in " +
|
|
50
|
-
config.projectId);
|
|
51
|
-
instance.log("");
|
|
52
|
-
return [2 /*return*/];
|
|
53
|
-
});
|
|
54
|
-
}); };
|
|
55
|
-
exports.setupCloudSQL = setupCloudSQL;
|
|
56
|
-
//# sourceMappingURL=setupCloudSQL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupCloudSQL.js","sourceRoot":"","sources":["../../../../../../src/apps/cli/commands/project/setup/setupCloudSQL.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAG6B;AAGtB,IAAM,aAAa,GAAG,UAC3B,QAAyB,EACzB,OAAgB;;;QAEhB,IAAI,CAAC,IAAA,gCAAqB,EAAC,OAAO,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;QACK,MAAM,GAAG,IAAA,sCAA2B,EAAC,OAAO,CAAC,CAAC;QACpD,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjB,QAAQ,CAAC,GAAG,CACV,uFAAuF;YACrF,MAAM,CAAC,SAAS,CACnB,CAAC;QACF,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;;KAClB,CAAC;AAdW,QAAA,aAAa,iBAcxB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@catladder/pipeline";
|
|
2
|
-
import {
|
|
3
|
-
getKubernetesCloudSQLConfig,
|
|
4
|
-
hasKubernetesCloudSQL,
|
|
5
|
-
} from "@catladder/pipeline";
|
|
6
|
-
import type { CommandInstance } from "vorpal";
|
|
7
|
-
|
|
8
|
-
export const setupCloudSQL = async (
|
|
9
|
-
instance: CommandInstance,
|
|
10
|
-
context: Context
|
|
11
|
-
) => {
|
|
12
|
-
if (!hasKubernetesCloudSQL(context)) {
|
|
13
|
-
throw new Error("cannot setup cloudsql, as it has none");
|
|
14
|
-
}
|
|
15
|
-
const config = getKubernetesCloudSQLConfig(context);
|
|
16
|
-
instance.log("");
|
|
17
|
-
instance.log(
|
|
18
|
-
"! make sure to provide cloudsqlProxyCredentials for the cloud sql service account in " +
|
|
19
|
-
config.projectId
|
|
20
|
-
);
|
|
21
|
-
instance.log("");
|
|
22
|
-
};
|