@catladder/pipeline 1.169.0 → 1.170.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.
@@ -0,0 +1,11 @@
1
+ import { createYamlLocalPipeline } from "./__utils__/helpers";
2
+ import config from "./cloud-run-service-custom-vpc-connector";
3
+
4
+ /**
5
+ * This test is auto-generated.
6
+ * Modifications will be overwritten on every `yarn test` run!
7
+ */
8
+
9
+ it("matches snapshot for cloud-run-service-custom-vpc-connector local pipeline YAML", async () => {
10
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
11
+ });
@@ -0,0 +1,30 @@
1
+ import type { Config } from "../src";
2
+
3
+ const config: Config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ api: {
8
+ dir: "api",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ deploy: {
13
+ type: "google-cloudrun",
14
+ projectId: "google-project-id",
15
+ region: "europe-west6",
16
+
17
+ service: {
18
+ vpcConnector: "my-first-vpc-connector",
19
+ vpcEgress: "all-traffic",
20
+ },
21
+ },
22
+ },
23
+ },
24
+ };
25
+
26
+ export default config;
27
+
28
+ export const information = {
29
+ title: "Cloud Run: Service with custom vpc settings",
30
+ };
@@ -15,7 +15,8 @@ const config: Config = {
15
15
  region: "europe-west6",
16
16
 
17
17
  service: {
18
- vpcConnector: "my-first-vpc-connector",
18
+ network: "my-network",
19
+ subnet: "my-subnet",
19
20
  vpcEgress: "all-traffic",
20
21
  },
21
22
  },
@@ -4,20 +4,54 @@ const config: Config = {
4
4
  appName: "test-app",
5
5
  customerName: "pan",
6
6
  components: {
7
- api: {
8
- dir: "api",
7
+ app1: {
8
+ dir: "app1",
9
9
  build: {
10
10
  type: "node",
11
11
  },
12
12
  vars: {
13
13
  public: {
14
14
  foo: "foo-value",
15
- multiline: `line1
16
- line2
17
- line3
15
+ multiline: `app1 line1
16
+ app1 line2
17
+ app1 line3
18
18
 
19
- single quote: '
20
- doouble quote: "
19
+ the url of self: "\${ROOT_URL}"
20
+
21
+
22
+ app1 single quote: '
23
+ app1 doouble quote: "
24
+ `,
25
+ },
26
+ },
27
+ deploy: {
28
+ type: "google-cloudrun",
29
+ projectId: "asdf",
30
+ region: "asia-east1",
31
+ },
32
+ },
33
+ app2: {
34
+ dir: "app2",
35
+ build: {
36
+ type: "node",
37
+ },
38
+ vars: {
39
+ public: {
40
+ foo: "foo-value",
41
+ multiline: `app2 yeah
42
+ app2 yeah2
43
+ app2 yeah3
44
+
45
+ app2 single quote: '
46
+ app2 doouble quote: "
47
+
48
+ the url of self: "\${ROOT_URL}"
49
+ the url of app1: "\${app1:ROOT_URL}"
50
+
51
+ value from app1:
52
+ -------
53
+ \${multiline_from_app1}
54
+ --------
21
55
  `,
22
56
  },
23
57
  },
@@ -27,20 +61,28 @@ doouble quote: "
27
61
  region: "asia-east1",
28
62
  },
29
63
  },
30
- api2: {
31
- dir: "api",
64
+ kube: {
65
+ dir: "kube",
32
66
  build: {
33
67
  type: "node",
34
68
  },
35
69
  vars: {
36
70
  public: {
37
- multiline_from_api: "${api:multiline}",
38
- multiline2: `yeah
39
- yeah2
40
- yeah3
71
+ multiline_from_app1: "${app1:multiline}",
72
+ multiline: `kube yeah
73
+ kube yeah2
74
+ kube yeah3
75
+
76
+ kube single quote: '
77
+ kube doouble quote: "
78
+
79
+ the url of self: "\${ROOT_URL}"
80
+ the url of app1: "\${app1:ROOT_URL}"
41
81
 
42
- single quote: '
43
- doouble quote: "
82
+ value from app1:
83
+ -------
84
+ \${multiline_from_app1}
85
+ --------
44
86
  `,
45
87
  },
46
88
  },
@@ -0,0 +1,11 @@
1
+ import { createYamlLocalPipeline } from "./__utils__/helpers";
2
+ import config from "./referencing-other-vars";
3
+
4
+ /**
5
+ * This test is auto-generated.
6
+ * Modifications will be overwritten on every `yarn test` run!
7
+ */
8
+
9
+ it("matches snapshot for referencing-other-vars local pipeline YAML", async () => {
10
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
11
+ });
@@ -0,0 +1,83 @@
1
+ import type { Config } from "../src";
2
+
3
+ const config: Config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ app1: {
8
+ dir: "app1",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ vars: {
13
+ secret: ["SECRET1"],
14
+ public: {
15
+ foo: "foo-value",
16
+ bar: "bar-value",
17
+ foo3: "from app3: ${app3:foo3}",
18
+ circle:
19
+ 'this is from app3 that has reference to app1: "${app3:transitive}"', // not officially recommended, but may work in some cases
20
+ },
21
+ },
22
+ deploy: {
23
+ type: "google-cloudrun",
24
+ projectId: "asdf",
25
+ region: "asia-east1",
26
+ },
27
+ },
28
+ app2: {
29
+ dir: "app2",
30
+ build: {
31
+ type: "node",
32
+ },
33
+ vars: {
34
+ secret: ["SECRET2"],
35
+ public: {
36
+ foo2: "foo-value-2",
37
+ referencingSecret: "secret1: ${app1:SECRET1}, secret2: ${SECRET2}",
38
+ foo1: "this is from app1: ${app1:foo}",
39
+ selfReference: "this is from self: ${foo2}",
40
+ selfReference2: "this is from self: ${foo1}",
41
+ app1Api: "${app1:ROOT_URL}/graphql",
42
+ },
43
+ },
44
+ deploy: {
45
+ type: "google-cloudrun",
46
+ projectId: "asdf",
47
+ region: "asia-east1",
48
+ },
49
+ },
50
+ app3: {
51
+ dir: "kube",
52
+ build: {
53
+ type: "node",
54
+ },
55
+ vars: {
56
+ public: {
57
+ foo3: "foo-value-3",
58
+ foo2: "this is from app2: ${app2:foo2}",
59
+ transitive: "this is from app2: ${app2:foo1}",
60
+ transitiveWithSecret: "this is from app2: ${app2:referencingSecret}",
61
+ someJson:
62
+ '[{"name": "app1", "url": "${app1:ROOT_URL}"}, {"name": "app2", "url": "${app2:ROOT_URL}"}, {"name": "app3", "url": "${ROOT_URL}"}]',
63
+ },
64
+ },
65
+ deploy: {
66
+ type: "kubernetes",
67
+ cluster: {
68
+ name: "some-cluster-name",
69
+ region: "europe-west6",
70
+ projectId: "some-project-id",
71
+ type: "gcloud",
72
+ domainCanonical: "panter.cloud",
73
+ },
74
+ },
75
+ },
76
+ },
77
+ };
78
+
79
+ export default config;
80
+
81
+ export const information = {
82
+ title: "Multiline Environment Variables",
83
+ };
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "1.169.0",
56
+ "version": "1.170.1",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
59
59
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -12,6 +12,16 @@ export class BashExpression {
12
12
  return this.value.toString();
13
13
  }
14
14
 
15
+ public replace(
16
+ searchValue: any,
17
+
18
+ replacer: (substring: string, ...args: any[]) => string,
19
+ ) {
20
+ return new BashExpression(
21
+ this.value.toString().replace(searchValue, replacer),
22
+ );
23
+ }
24
+
15
25
  /**
16
26
  *
17
27
  * @returns a bash expression to lowercase the string
@@ -1,4 +1,4 @@
1
- import { BashExpression } from "./BashExpression";
1
+ import { BashExpression, bashEscape } from "./BashExpression";
2
2
 
3
3
  // from https://github.com/dsblv/string-replace-async/blob/main/index.js
4
4
  // and adjusted a bit
@@ -11,13 +11,14 @@ export default async function replaceAsync(
11
11
  ) => Promise<string | BashExpression>,
12
12
  ) {
13
13
  const wasBashExpression = string instanceof BashExpression;
14
+
14
15
  try {
15
16
  // 1. Run fake pass of `replace`, collect values from `replacer` calls
16
17
  // 2. Resolve them with `Promise.all`
17
18
  // 3. Run `replace` with resolved values
18
19
  const values: Array<Promise<string | BashExpression>> = [];
19
20
  String.prototype.replace.call(
20
- string.toString(),
21
+ string instanceof BashExpression ? string : bashEscape(string),
21
22
  searchValue,
22
23
  function (...args) {
23
24
  // eslint-disable-next-line prefer-spread
@@ -31,14 +32,12 @@ export default async function replaceAsync(
31
32
  const containsBashExpression = resolvedValues.some(
32
33
  (value) => value instanceof BashExpression,
33
34
  );
35
+ const result = (
36
+ string instanceof BashExpression ? string : bashEscape(string)
37
+ ).replace(searchValue, function () {
38
+ return resolvedValues.shift()?.toString() ?? "";
39
+ });
34
40
 
35
- const result = String.prototype.replace.call(
36
- string.toString(),
37
- searchValue,
38
- function () {
39
- return resolvedValues.shift()?.toString() ?? "";
40
- },
41
- );
42
41
  if (wasBashExpression || containsBashExpression) {
43
42
  return new BashExpression(result);
44
43
  } else {
@@ -52,6 +52,8 @@ export const getServiceDeployScript = (
52
52
  timeout: customConfig?.timeout,
53
53
  "vpc-connector": customConfig?.vpcConnector,
54
54
  "vpc-egress": customConfig?.vpcEgress,
55
+ network: customConfig?.network,
56
+ subnet: customConfig?.subnet,
55
57
  "use-http2": customConfig?.http2,
56
58
  "allow-unauthenticated": customConfig?.allowUnauthenticated ?? true,
57
59
  ingress: customConfig?.ingress ?? "all",
@@ -158,15 +158,23 @@ export type DeployConfigCloudRunService = {
158
158
  */
159
159
  executionEnvironment?: "gen2" | "gen1";
160
160
 
161
+ /* the vpc network, see https://cloud.google.com/sdk/gcloud/reference/run/deploy#--network */
162
+ network?: string;
163
+
161
164
  /**
162
- * vpc connector,
165
+ * vpc subnet to use, see https://cloud.google.com/sdk/gcloud/reference/run/deploy#--subnet
163
166
  */
164
- vpcConnector?: string;
167
+ subnet?: string;
165
168
  /**
166
169
  * vpc egress, see https://cloud.google.com/sdk/gcloud/reference/run/deploy#--vpc-egress
167
170
  */
168
171
  vpcEgress?: "all-traffic" | "private-ranges-only";
169
172
 
173
+ /**
174
+ * vpc connector
175
+ */
176
+ vpcConnector?: string;
177
+
170
178
  /**
171
179
  * Use http2 end-to-end. See https://cloud.google.com/run/docs/configuring/http2
172
180
  *