@catladder/cli 1.90.0 → 1.91.1

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/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "node": ">=12.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@catladder/pipeline": "1.90.0",
27
+ "@catladder/pipeline": "1.91.1",
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.90.0"
60
+ "version": "1.91.1"
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";
@@ -60,35 +61,14 @@ export default async (vorpal: Vorpal) =>
60
61
  );
61
62
  this.log("");
62
63
 
63
- // legacy, some projects have the cloudsqlProxyCredentials in the secrets
64
- // actually it works without, if the current local shell user has access to the db through google cloud
65
- const cloudsqlProxyCredentials = await getGitlabVar(
66
- this,
67
- env,
68
- componentName,
69
- "cloudsqlProxyCredentials"
70
- );
71
-
72
- await withFile(async ({ path: tmpFilePath }) => {
73
- if (cloudsqlProxyCredentials) {
74
- await writeFile(tmpFilePath, cloudsqlProxyCredentials);
64
+ await spawn(
65
+ "cloud_sql_proxy",
66
+ ["-instances", `${instanceName}=tcp:${localPort}`],
67
+ {
68
+ stdio: "inherit",
69
+ shell: true,
75
70
  }
76
-
77
- await spawn(
78
- "cloud_sql_proxy",
79
- [
80
- "-instances",
81
- `${instanceName}=tcp:${localPort}`,
82
- ...(cloudsqlProxyCredentials
83
- ? ["-credential_file", tmpFilePath]
84
- : []),
85
- ],
86
- {
87
- stdio: "inherit",
88
- shell: true,
89
- }
90
- );
91
- });
71
+ );
92
72
  });
93
73
 
94
74
  const getProxyInfoForKubernetes = async (
@@ -103,24 +83,14 @@ const getProxyInfoForKubernetes = async (
103
83
  context.environment.shortName,
104
84
  context.componentName
105
85
  );
86
+ // bit hacky, would be nicer if we would also declare this through env vars
87
+ const cloudSqlValues = createKubernetesCloudsqlBaseValues(context);
106
88
 
107
89
  const DB_PASSWORD = envVars?.DB_PASSWORD || envVars?.POSTGRESQL_PASSWORD;
108
90
 
109
- const DB_NAME = context.environment.envVars.KUBE_APP_NAME;
110
-
111
- const values = context.componentConfig.deploy.values;
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;
91
+ const DB_NAME = cloudSqlValues.cloudsql.fullDbName;
122
92
 
123
- const instanceName = `${projectId}:${region}:${instanceId}`;
93
+ const instanceName = cloudSqlValues.cloudsql.instanceConnectionName;
124
94
 
125
95
  return {
126
96
  instanceName,
@@ -1,8 +1,8 @@
1
1
  import type { Context } from "@catladder/pipeline";
2
- import { isOfDeployType, hasKubernetesCloudSQL } from "@catladder/pipeline";
2
+ import { isOfDeployType } from "@catladder/pipeline";
3
3
  import type { CommandInstance } from "vorpal";
4
4
  import { setupCloudRun } from "./setupCloudRun";
5
- import { setupCloudSQL } from "./setupCloudSQL";
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")) {
@@ -1,3 +0,0 @@
1
- import type { Context } from "@catladder/pipeline";
2
- import type { CommandInstance } from "vorpal";
3
- export declare const setupCloudSQL: (instance: CommandInstance, context: Context) => Promise<void>;
@@ -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
- };