@catladder/pipeline 0.0.0-refactor-untangle-gitlab-api-requests-from-vorpal-57cf3cf2 → 0.0.0-reference-database-url-1befbbee

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.
Files changed (181) hide show
  1. package/dist/build/artifacts/createBuildJobArtifact.js +1 -1
  2. package/dist/build/base/index.d.ts +2 -3
  3. package/dist/build/cache/getAllCacheConfigsFromConfig.js +2 -2
  4. package/dist/build/custom/buildJob.d.ts +2 -2
  5. package/dist/build/custom/index.d.ts +2 -2
  6. package/dist/build/custom/testJob.d.ts +2 -2
  7. package/dist/build/docker.d.ts +4 -4
  8. package/dist/build/docker.js +1 -1
  9. package/dist/build/index.d.ts +2 -2
  10. package/dist/build/index.js +2 -3
  11. package/dist/build/node/buildJob.d.ts +5 -3
  12. package/dist/build/node/index.d.ts +4 -4
  13. package/dist/build/node/meteor.d.ts +2 -2
  14. package/dist/build/node/yarn.d.ts +1 -1
  15. package/dist/build/node/yarn.js +1 -1
  16. package/dist/build/rails/build.d.ts +2 -2
  17. package/dist/build/rails/build.js +1 -1
  18. package/dist/build/rails/index.d.ts +2 -2
  19. package/dist/build/rails/test.js +13 -2
  20. package/dist/build/sbom.d.ts +2 -2
  21. package/dist/build/sbom.js +4 -1
  22. package/dist/build/types.d.ts +8 -0
  23. package/dist/constants.js +1 -1
  24. package/dist/context/createComponentContext.js +11 -4
  25. package/dist/context/getLabels.js +1 -1
  26. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +2 -2
  27. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +34 -12
  28. package/dist/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +2 -3
  29. package/dist/deploy/cloudRun/createJobs/execute/onDeploy.js +4 -9
  30. package/dist/deploy/cloudRun/createJobs/healthCheck.d.ts +5 -0
  31. package/dist/deploy/cloudRun/createJobs/healthCheck.js +82 -0
  32. package/dist/deploy/cloudRun/index.js +7 -5
  33. package/dist/deploy/cloudRun/utils/database.d.ts +21 -2
  34. package/dist/deploy/cloudRun/utils/database.js +27 -6
  35. package/dist/deploy/cloudRun/utils/getJobOrServiceArgs.d.ts +2 -0
  36. package/dist/deploy/cloudRun/utils/getJobOrServiceArgs.js +12 -0
  37. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  38. package/dist/deploy/kubernetes/kubeValues.js +1 -1
  39. package/dist/deploy/sbom.js +1 -1
  40. package/dist/deploy/types/googleCloudRun.d.ts +100 -0
  41. package/dist/deploy/types/googleCloudRun.js +25 -0
  42. package/dist/pipeline/createJobsForComponent.js +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/dist/types/config.d.ts +1 -1
  45. package/dist/types/context.d.ts +6 -1
  46. package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +1394 -0
  47. package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +1394 -0
  48. package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +1394 -0
  49. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +20 -8
  50. package/examples/__snapshots__/cloud-run-llama.test.ts.snap +624 -0
  51. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +20 -8
  52. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +24 -12
  53. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +20 -8
  54. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +20 -8
  55. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +20 -8
  56. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +20 -8
  57. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +20 -8
  58. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +20 -8
  59. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +20 -8
  60. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +20 -8
  61. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +20 -8
  62. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +20 -8
  63. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +20 -8
  64. package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +1394 -0
  65. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +20 -8
  66. package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +20 -8
  67. package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +4515 -0
  68. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +40 -16
  69. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +20 -8
  70. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +20 -8
  71. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +20 -8
  72. package/examples/__snapshots__/custom-build-job.test.ts.snap +20 -8
  73. package/examples/__snapshots__/custom-deploy.test.ts.snap +20 -8
  74. package/examples/__snapshots__/custom-envs.test.ts.snap +24 -6
  75. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +4 -4
  76. package/examples/__snapshots__/custom-verify-job.test.ts.snap +20 -8
  77. package/examples/__snapshots__/git-submodule.test.ts.snap +20 -8
  78. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +20 -8
  79. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +20 -8
  80. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +40 -16
  81. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +20 -8
  82. package/examples/__snapshots__/local-dot-env.test.ts.snap +20 -8
  83. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +20 -8
  84. package/examples/__snapshots__/multiline-var.test.ts.snap +60 -24
  85. package/examples/__snapshots__/native-app.test.ts.snap +36 -12
  86. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +20 -8
  87. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +20 -8
  88. package/examples/__snapshots__/override-secrets.test.ts.snap +20 -8
  89. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +30 -17
  90. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +38 -29
  91. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +60 -24
  92. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +32 -8
  93. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +40 -16
  94. package/examples/__snapshots__/workspace-api-www.test.ts.snap +40 -16
  95. package/examples/cloud-run-health-check-defaults.test.ts +11 -0
  96. package/examples/cloud-run-health-check-defaults.ts +28 -0
  97. package/examples/cloud-run-health-check-only-startup.test.ts +11 -0
  98. package/examples/cloud-run-health-check-only-startup.ts +38 -0
  99. package/examples/cloud-run-health-check.test.ts +11 -0
  100. package/examples/cloud-run-health-check.ts +45 -0
  101. package/examples/cloud-run-http2.ts +2 -2
  102. package/examples/cloud-run-llama.test.ts +11 -0
  103. package/examples/cloud-run-llama.ts +40 -0
  104. package/examples/cloud-run-memory-limit.ts +2 -2
  105. package/examples/cloud-run-meteor-with-worker.ts +7 -3
  106. package/examples/cloud-run-nextjs.ts +2 -2
  107. package/examples/cloud-run-no-cpu-throttling.ts +2 -2
  108. package/examples/cloud-run-no-service.ts +2 -2
  109. package/examples/cloud-run-non-public.ts +2 -2
  110. package/examples/cloud-run-post-stop-job.ts +2 -2
  111. package/examples/cloud-run-service-custom-vpc-connector.ts +2 -2
  112. package/examples/cloud-run-service-custom-vpc.ts +2 -2
  113. package/examples/cloud-run-service-gen2.ts +2 -2
  114. package/examples/cloud-run-service-increase-timout.ts +2 -2
  115. package/examples/cloud-run-service-with-volumes.ts +2 -2
  116. package/examples/cloud-run-storybook.ts +2 -2
  117. package/examples/cloud-run-with-gpu.test.ts +11 -0
  118. package/examples/cloud-run-with-gpu.ts +30 -0
  119. package/examples/cloud-run-with-ngnix.ts +2 -2
  120. package/examples/cloud-run-with-sql-legacy-jobs.ts +2 -2
  121. package/examples/cloud-run-with-sql-multiple-dbs.test.ts +11 -0
  122. package/examples/cloud-run-with-sql-multiple-dbs.ts +87 -0
  123. package/examples/cloud-run-with-sql-reuse-db.ts +2 -2
  124. package/examples/cloud-run-with-sql.ts +2 -2
  125. package/examples/cloud-run-with-worker.ts +2 -2
  126. package/examples/custom-build-job-with-tests.ts +2 -2
  127. package/examples/custom-build-job.ts +2 -2
  128. package/examples/custom-deploy.ts +2 -2
  129. package/examples/custom-envs.ts +2 -2
  130. package/examples/custom-sbom-java.ts +2 -2
  131. package/examples/custom-verify-job.ts +2 -2
  132. package/examples/git-submodule.ts +2 -2
  133. package/examples/kubernetes-application-customization.ts +2 -2
  134. package/examples/kubernetes-with-cloud-sql.ts +2 -2
  135. package/examples/kubernetes-with-jobs.ts +2 -2
  136. package/examples/kubernetes-with-mongodb.ts +2 -2
  137. package/examples/local-dot-env.ts +2 -2
  138. package/examples/meteor-kubernetes.ts +2 -2
  139. package/examples/multiline-var.ts +2 -2
  140. package/examples/native-app.ts +2 -2
  141. package/examples/node-build-with-custom-image.ts +2 -2
  142. package/examples/node-build-with-docker-additions.ts +2 -2
  143. package/examples/override-secrets.ts +2 -2
  144. package/examples/rails-k8s-with-worker.ts +2 -2
  145. package/examples/referencing-other-vars.ts +2 -2
  146. package/examples/wait-for-other-deploy.ts +1 -1
  147. package/examples/workspace-api-www-turbo-cache.ts +2 -2
  148. package/examples/workspace-api-www.ts +2 -2
  149. package/package.json +1 -1
  150. package/src/build/artifacts/createBuildJobArtifact.ts +3 -1
  151. package/src/build/base/index.ts +5 -2
  152. package/src/build/cache/getAllCacheConfigsFromConfig.ts +7 -6
  153. package/src/build/custom/buildJob.ts +2 -2
  154. package/src/build/custom/index.ts +4 -2
  155. package/src/build/custom/testJob.ts +2 -2
  156. package/src/build/docker.ts +9 -5
  157. package/src/build/index.ts +7 -5
  158. package/src/build/node/buildJob.ts +5 -2
  159. package/src/build/node/index.ts +9 -4
  160. package/src/build/node/meteor.ts +5 -2
  161. package/src/build/node/yarn.ts +4 -2
  162. package/src/build/rails/build.ts +3 -8
  163. package/src/build/rails/index.ts +4 -2
  164. package/src/build/rails/test.ts +19 -0
  165. package/src/build/sbom.ts +8 -3
  166. package/src/build/types.ts +8 -0
  167. package/src/context/createComponentContext.ts +22 -9
  168. package/src/context/getLabels.ts +4 -1
  169. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +2 -2
  170. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +30 -3
  171. package/src/deploy/cloudRun/createJobs/execute/onDeploy.ts +3 -13
  172. package/src/deploy/cloudRun/createJobs/healthCheck.ts +64 -0
  173. package/src/deploy/cloudRun/index.ts +14 -5
  174. package/src/deploy/cloudRun/utils/database.ts +93 -8
  175. package/src/deploy/cloudRun/utils/getJobOrServiceArgs.ts +18 -0
  176. package/src/deploy/kubernetes/kubeValues.ts +13 -4
  177. package/src/deploy/sbom.ts +4 -3
  178. package/src/deploy/types/googleCloudRun.ts +135 -0
  179. package/src/pipeline/createJobsForComponent.ts +10 -2
  180. package/src/types/config.ts +1 -1
  181. package/src/types/context.ts +10 -1
@@ -3,8 +3,10 @@ import type { ComponentContext } from "../../../../types/context";
3
3
  import type {
4
4
  DeployConfigCloudRunExecuteOnDeploy,
5
5
  DeployConfigCloudRunJob,
6
+ DeployConfigCloudRunService,
6
7
  } from "../../../types/googleCloudRun";
7
8
  import { createArgsString } from "../../utils/createArgsString";
9
+ import { getCloudRunServiceOrJobArgsArg } from "../../utils/getJobOrServiceArgs";
8
10
  import { getFullJobName } from "../../utils/jobName";
9
11
  import { getCloudRunJobsWithNames } from "../cloudRunJobs";
10
12
  import {
@@ -93,20 +95,8 @@ const getJobRunScriptForExecute = (
93
95
  const argString = createArgsString({
94
96
  ...commonArgs,
95
97
  wait: waitForCompletion === true ? true : undefined,
96
- args: getCloudRunJobArgsArg(config.args),
98
+ args: getCloudRunServiceOrJobArgsArg(config.args),
97
99
  });
98
100
  const fullJobName = getFullJobName(context, jobName);
99
101
  return `${gcloudRunCmd()} jobs execute ${fullJobName.toString()} ${argString}`;
100
102
  };
101
-
102
- export const getCloudRunJobArgsArg = (
103
- args:
104
- | DeployConfigCloudRunExecuteOnDeploy["args"]
105
- | DeployConfigCloudRunJob["args"],
106
- ) => {
107
- return args !== undefined
108
- ? args.length > 0
109
- ? args?.map((arg) => `"${arg}"`).join(",")
110
- : ""
111
- : undefined;
112
- };
@@ -0,0 +1,64 @@
1
+ import type { DeployConfigCloudRunProbeShared } from "../../types";
2
+ import {
3
+ defaultLivenessProbe,
4
+ defaultStartupProbe,
5
+ type DeployConfigCloudRunProbe,
6
+ type DeployConfigCloudRunService,
7
+ } from "../../types";
8
+
9
+ const PORT = 8080;
10
+
11
+ export function healthCheckCliArgs(
12
+ healthCheck: DeployConfigCloudRunService["healthCheck"],
13
+ ) {
14
+ const shouldNotSetHealthCheck = healthCheck === undefined;
15
+ if (shouldNotSetHealthCheck) {
16
+ return undefined;
17
+ }
18
+
19
+ const shouldUseDefaultProbe = healthCheck === true;
20
+
21
+ if (shouldUseDefaultProbe) {
22
+ return {
23
+ "startup-probe": toArgValue(probeToKeyValuePairs(defaultStartupProbe)),
24
+ "liveness-probe": toArgValue(probeToKeyValuePairs(defaultLivenessProbe)),
25
+ };
26
+ }
27
+
28
+ return {
29
+ "startup-probe": toArgValue(probeToKeyValuePairs(healthCheck.startupProbe)),
30
+ "liveness-probe": healthCheck.livenessProbe
31
+ ? toArgValue(probeToKeyValuePairs(healthCheck.livenessProbe))
32
+ : "", // NOTE: empty string ("") removes liveness probe
33
+ };
34
+ }
35
+
36
+ function probeToKeyValuePairs(
37
+ probe: DeployConfigCloudRunProbe,
38
+ ): [string, unknown][] {
39
+ const sharedArgs = Object.entries({
40
+ initialDelaySeconds: probe.initialDelaySeconds,
41
+ timeoutSeconds: probe.timeoutSeconds,
42
+ periodSeconds: probe.periodSeconds,
43
+ failureThreshold: probe.failureThreshold,
44
+ } satisfies DeployConfigCloudRunProbeShared);
45
+
46
+ switch (probe.type) {
47
+ case "tcp":
48
+ return [...sharedArgs, ["tcpSocket.port", PORT]];
49
+ case "http1":
50
+ return [
51
+ ...sharedArgs,
52
+ ["httpGet.port", PORT],
53
+ ["httpGet.path", probe.path],
54
+ // NOTE: headers are not supported by "gcloud beta" at the moment
55
+ ];
56
+ default:
57
+ probe satisfies never;
58
+ return [];
59
+ }
60
+ }
61
+
62
+ function toArgValue(keyValues: [string, unknown][]) {
63
+ return keyValues.map(([key, value]) => `${key}=${value}`).join(",");
64
+ }
@@ -11,8 +11,9 @@ import { getFullDbName } from "../cloudSql/utils";
11
11
  import { createGoogleCloudRunDeployJobs } from "./createJobs";
12
12
  import { getCloudRunJobExecuteUrl } from "./utils/cloudRunExecutionUrl";
13
13
  import {
14
- DATABASE_JDBC_URL,
14
+ DEFAULT_DB_VARIABLES_MODE,
15
15
  getDatabaseConnectionString,
16
+ getDatabaseJdbcUrl,
16
17
  } from "./utils/database";
17
18
 
18
19
  export const GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
@@ -42,16 +43,24 @@ const getCloudSqlVariables = ({
42
43
  .map(([key, value]) => `&${key}=${value}`)
43
44
  .join("");
44
45
 
45
- return {
46
+ const dbVars = {
46
47
  CLOUD_SQL_INSTANCE_CONNECTION_NAME:
47
48
  deployConfigRaw.cloudSql.instanceConnectionName,
48
49
  DB_NAME: DB_NAME,
49
50
  DB_USER: deployConfigRaw.cloudSql.dbUser ?? "postgres",
50
51
  DB_PASSWORD: "$" + getSecretVarName(env, componentName, "DB_PASSWORD"),
51
- DATABASE_URL: `${getDatabaseConnectionString(
52
+ };
53
+ return {
54
+ ...dbVars,
55
+ DATABASE_URL: getDatabaseConnectionString(
52
56
  deployConfigRaw.cloudSql,
53
- )}${additionalQueryParamsString}`,
54
- DATABASE_JDBC_URL: DATABASE_JDBC_URL,
57
+ dbVars,
58
+ ).concat(additionalQueryParamsString),
59
+ DATABASE_JDBC_URL: getDatabaseJdbcUrl(
60
+ dbVars,
61
+ deployConfigRaw.cloudSql.dbConnectionStringVariablesMode ??
62
+ DEFAULT_DB_VARIABLES_MODE,
63
+ ),
55
64
  };
56
65
  }
57
66
  return {};
@@ -1,3 +1,8 @@
1
+ import {
2
+ BashExpression,
3
+ joinBashExpressions,
4
+ type StringOrBashExpression,
5
+ } from "../../../bash";
1
6
  import type { ComponentContext } from "../../../types";
2
7
  import { allowFailureInScripts, repeatOnFailure } from "../../../utils/gitlab";
3
8
  import type {
@@ -57,21 +62,101 @@ export const getDatabaseCreateScript = (
57
62
  ]);
58
63
  };
59
64
 
60
- export const DATABASE_JDBC_URL =
61
- "jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD";
65
+ export type DBVariables = {
66
+ CLOUD_SQL_INSTANCE_CONNECTION_NAME: StringOrBashExpression;
67
+ DB_NAME: StringOrBashExpression;
68
+ DB_USER: StringOrBashExpression;
69
+ DB_PASSWORD: StringOrBashExpression;
70
+ };
71
+
72
+ /**
73
+ * controls how variables in the connection string are handled
74
+ *
75
+ * - legacy: variables like $DB_USER will be kept as environment variables to be replaced at runtime (default). It is not using BashExpressions as this was not the case in the past.
76
+ * - embedded: variables will be replaced with their actual values in the connection string
77
+ *
78
+ * We will remove the legacy mode in the future, as it is confusing. But its unclear whether its a breaking change in some edge cases
79
+ */
80
+ export type DBVariablesMode = "legacy" | "embedded";
81
+
82
+ export const DEFAULT_DB_VARIABLES_MODE: DBVariablesMode = "legacy";
83
+
84
+ const getVariableOrValue = (
85
+ key: keyof DBVariables,
86
+ variables: DBVariables,
87
+ mode: DBVariablesMode,
88
+ ): StringOrBashExpression => {
89
+ return mode === "legacy" ? `$${key}` : variables[key];
90
+ };
91
+
92
+ export const getDatabaseJdbcUrl = (
93
+ variables: DBVariables,
94
+ mode: DBVariablesMode,
95
+ ) => {
96
+ const parts = [
97
+ "jdbc:postgresql:///",
98
+ getVariableOrValue("DB_NAME", variables, mode),
99
+ "?cloudSqlInstance=",
100
+ getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", variables, mode),
101
+ "&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=",
102
+ getVariableOrValue("DB_USER", variables, mode),
103
+ "&password=",
104
+ getVariableOrValue("DB_PASSWORD", variables, mode),
105
+ ];
106
+
107
+ return joinBashExpressions(parts);
108
+ };
109
+
110
+ export const getRailsDatabaseConnectionString = (
111
+ variables: DBVariables,
112
+ mode: DBVariablesMode,
113
+ ) => {
114
+ const parts = [
115
+ "postgresql://",
116
+ getVariableOrValue("DB_USER", variables, mode),
117
+ ":",
118
+ getVariableOrValue("DB_PASSWORD", variables, mode),
119
+ "@",
120
+ encodeURIComponent(
121
+ `/cloudsql/${variables.CLOUD_SQL_INSTANCE_CONNECTION_NAME}`,
122
+ ),
123
+ "/",
124
+ getVariableOrValue("DB_NAME", variables, mode),
125
+ "?",
126
+ ];
127
+ return joinBashExpressions(parts);
128
+ };
129
+
130
+ export const getPrismaDatabaseConnectionString = (
131
+ variables: DBVariables,
132
+ mode: DBVariablesMode,
133
+ ) => {
134
+ const parts = [
135
+ "postgresql://",
136
+ getVariableOrValue("DB_USER", variables, mode),
137
+ ":",
138
+ getVariableOrValue("DB_PASSWORD", variables, mode),
139
+ "@localhost/",
140
+ getVariableOrValue("DB_NAME", variables, mode),
141
+ "?host=/cloudsql/",
142
+ getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", variables, mode),
143
+ ];
144
+ return joinBashExpressions(parts);
145
+ };
62
146
 
63
147
  export const getDatabaseConnectionString = (
64
148
  config: DeployConfigCloudRunCloudSql,
65
- ): string => {
149
+ variables: DBVariables,
150
+ ): StringOrBashExpression => {
151
+ const mode =
152
+ config.dbConnectionStringVariablesMode ?? DEFAULT_DB_VARIABLES_MODE;
66
153
  switch (config.dbConnectionStringFormat) {
67
154
  case "jdbc":
68
- return DATABASE_JDBC_URL;
155
+ return getDatabaseJdbcUrl(variables, mode);
69
156
  case "rails":
70
- return `postgresql://$DB_USER:$DB_PASSWORD@${encodeURIComponent(
71
- `/cloudsql/${config.instanceConnectionName}`,
72
- )}/$DB_NAME?`;
157
+ return getRailsDatabaseConnectionString(variables, mode);
73
158
  default:
74
159
  // prisma
75
- return "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME";
160
+ return getPrismaDatabaseConnectionString(variables, mode);
76
161
  }
77
162
  };
@@ -0,0 +1,18 @@
1
+ import type {
2
+ DeployConfigCloudRunExecuteOnDeploy,
3
+ DeployConfigCloudRunJob,
4
+ DeployConfigCloudRunService,
5
+ } from "../../types";
6
+
7
+ export const getCloudRunServiceOrJobArgsArg = (
8
+ args:
9
+ | DeployConfigCloudRunExecuteOnDeploy["args"]
10
+ | DeployConfigCloudRunJob["args"]
11
+ | DeployConfigCloudRunService["args"],
12
+ ) => {
13
+ return args !== undefined
14
+ ? args.length > 0
15
+ ? args?.map((arg) => `"${arg}"`).join(",")
16
+ : ""
17
+ : undefined;
18
+ };
@@ -1,6 +1,9 @@
1
1
  import { merge } from "lodash";
2
2
 
3
- import type { ComponentContext } from "../../types/context";
3
+ import type {
4
+ BuildContextComponent,
5
+ ComponentContext,
6
+ } from "../../types/context";
4
7
  import { mergeWithMergingArrays } from "../../utils";
5
8
  import type { DeployConfigKubernetesValues } from "../types";
6
9
  import { isOfDeployType } from "../types";
@@ -13,7 +16,7 @@ import { createKubeEnv } from "./kubeEnv";
13
16
  import { createMongodbBaseConfig } from "./mongodb";
14
17
 
15
18
  const createAppConfig = (
16
- context: ComponentContext,
19
+ context: ComponentContext<BuildContextComponent>,
17
20
  application: DeployConfigKubernetesValues["application"],
18
21
  ): DeployConfigKubernetesValues["application"] => {
19
22
  if (application === false) {
@@ -27,7 +30,11 @@ const createAppConfig = (
27
30
  return mergeWithMergingArrays(
28
31
  {
29
32
  host: context.environment.envVars.HOSTNAME,
30
- command: command ?? context.build.config.startCommand,
33
+ command:
34
+ command ??
35
+ (context.build.type !== "disabled"
36
+ ? context.build.config.startCommand
37
+ : undefined),
31
38
  livenessProbe: {
32
39
  httpGet: {
33
40
  path: healthRoute ?? "__health",
@@ -55,7 +62,9 @@ const removeFalsy = <T>(record?: Record<string, false | T>) => {
55
62
  );
56
63
  };
57
64
 
58
- export const createKubeValues = (context: ComponentContext) => {
65
+ export const createKubeValues = (
66
+ context: ComponentContext<BuildContextComponent>,
67
+ ) => {
59
68
  const deployConfig = context.deploy?.config;
60
69
  if (!deployConfig) {
61
70
  return [];
@@ -6,9 +6,10 @@ import {
6
6
  } from "../types/context";
7
7
 
8
8
  export const sbomDeactivated = (context: ComponentContext) =>
9
- componentContextIsStandaloneBuild(context) &&
10
- context.build.config.type === "custom" &&
11
- context.build.config.sbom === false;
9
+ context.build.type === "disabled" ||
10
+ (componentContextIsStandaloneBuild(context) &&
11
+ context.build.config.type === "custom" &&
12
+ context.build.config.sbom === false);
12
13
 
13
14
  export const getDependencyTrackUploadScript = (
14
15
  context: ComponentContext,
@@ -1,3 +1,4 @@
1
+ import type { DBVariablesMode } from "../cloudRun/utils/database";
1
2
  import type { DeployConfigBase } from "./base";
2
3
 
3
4
  export type Gcloudregion =
@@ -77,6 +78,16 @@ export type DeployConfigCloudRunCloudSql = {
77
78
  */
78
79
  dbConnectionStringFormat?: "prisma" | "rails" | "jdbc";
79
80
 
81
+ /**
82
+ * controls how variables in the connection string are handled
83
+ *
84
+ * - environment: variables like $DB_USER will be kept as environment variables to be replaced at runtime (default)
85
+ * - embedded: variables will be replaced with their actual values in the connection string
86
+ *
87
+ * @default "environment"
88
+ */
89
+ dbConnectionStringVariablesMode?: DBVariablesMode;
90
+
80
91
  /**
81
92
  * add additional query params to the database connection string
82
93
  */
@@ -168,9 +179,133 @@ export type DeployConfigCloudRunService = {
168
179
  *
169
180
  */
170
181
  http2?: boolean;
182
+
183
+ /**
184
+ * Number of GPUs to use. Defaults to 0
185
+ *
186
+ * This is a preview feature and not all regions support it.
187
+ */
188
+ gpu?: number;
189
+
190
+ /**
191
+ * gpu type to use. Refer to https://cloud.google.com/run/docs/configuring/services/gpu#gcloud for defaults
192
+ */
193
+ gpuType?: string;
194
+
195
+ /**
196
+ * the image to use. Defaults to the image from the build.
197
+ *
198
+ * If you specify an image, you usually want to disable the build by setting build: false
199
+ */
200
+ image?: string;
201
+ /**
202
+ * args to pass to the command
203
+ */
204
+ args?: string[];
205
+
206
+ /**
207
+ * Configuration of the health check.
208
+ *
209
+ * When set to `true`, startup and liveness probes will be
210
+ * configured to `defaultStartupProbe` and `defaultLivenessProbe`.
211
+ *
212
+ * When not set, default Cloud Run's health check
213
+ * configuration is used (startup TCP probe and no liveness probe).
214
+ */
215
+ healthCheck?:
216
+ | true
217
+ | {
218
+ /**
219
+ * Startup probe configuration.
220
+ */
221
+ startupProbe: DeployConfigCloudRunProbe;
222
+
223
+ /**
224
+ * Liveness probe configuration.
225
+ * `false` disables the liveness probe.
226
+ */
227
+ livenessProbe: false | DeployConfigCloudRunProbe;
228
+ };
171
229
  } & DeployConfigCloudRunWithVolumes &
172
230
  DeployConfigCloudRunNetworkConfig;
173
231
 
232
+ export const defaultStartupProbe: DeployConfigCloudRunProbe = {
233
+ type: "http1",
234
+ path: "/__health",
235
+
236
+ initialDelaySeconds: 5,
237
+ timeoutSeconds: 1,
238
+ periodSeconds: 30,
239
+ failureThreshold: 3,
240
+ };
241
+
242
+ export const defaultLivenessProbe: DeployConfigCloudRunProbe = {
243
+ ...defaultStartupProbe,
244
+
245
+ initialDelaySeconds: 0,
246
+ timeoutSeconds: 10,
247
+ periodSeconds: 30,
248
+ failureThreshold: 3,
249
+ };
250
+
251
+ export type DeployConfigCloudRunProbe =
252
+ | DeployConfigCloudRunHttp1Probe
253
+ | DeployConfigCloudRunTcpProbe;
254
+
255
+ export type DeployConfigCloudRunProbeShared = {
256
+ /**
257
+ * The period in seconds at which to perform the probe.
258
+ * For example 2 to perform the probe every 2 seconds.
259
+ * Specify a value **from 1 second to 240** seconds.
260
+ */
261
+ periodSeconds: number;
262
+
263
+ /**
264
+ * The number of seconds to wait after the container has started before performing the first probe.
265
+ * Specify a value **from 0 seconds to 240** seconds.
266
+ */
267
+ initialDelaySeconds: number;
268
+
269
+ /**
270
+ * The number of seconds to wait until the probe times out.
271
+ * This value cannot exceed the value specified for `period`.
272
+ * Specify a value **from 1 to 240**.
273
+ */
274
+ timeoutSeconds: number;
275
+
276
+ /**
277
+ * The number of times to retry the probe before shutting down the container.
278
+ */
279
+ failureThreshold: number;
280
+ };
281
+
282
+ export type DeployConfigCloudRunTcpProbe = DeployConfigCloudRunProbeShared & {
283
+ /**
284
+ * Cloud Run makes a TCP connection to open the TCP Socket on the specified port.
285
+ * If Cloud Run is unable to establish a connection, it indicates a failure.
286
+ */
287
+ type: "tcp";
288
+ };
289
+
290
+ export type DeployConfigCloudRunHttp1Probe = DeployConfigCloudRunProbeShared & {
291
+ /**
292
+ * **This will NOT work with http2 enabled services**
293
+ *
294
+ * Cloud Run makes an HTTP GET request to the service health check endpoint (for example, /ready).
295
+ * Any response between 200 and 400 is a success, everything else indicates failure.
296
+ *
297
+ * If a startup probe does not succeed within the specified time (failureThreshold * period), which cannot exceed 240 seconds, the container is shut down.
298
+ *
299
+ * If the HTTP startup probe succeeds within the specified time, and you have enabled liveness probe, the HTTP liveness probe is started.
300
+ */
301
+ type: "http1";
302
+
303
+ /**
304
+ * the route path to check for health status of the service starting with a `/`.
305
+ */
306
+ path: string;
307
+ };
308
+
174
309
  export type DeployConfigCloudRunNetworkConfig = {
175
310
  /* the vpc network, see https://cloud.google.com/sdk/gcloud/reference/run/deploy#--network */
176
311
  network?: string;
@@ -1,6 +1,9 @@
1
1
  import { BUILD_TYPES } from "../build";
2
2
  import { DEPLOY_TYPES } from "../deploy";
3
- import type { ComponentContext } from "../types/context";
3
+ import type {
4
+ ComponentContext,
5
+ ComponentContextWithBuild,
6
+ } from "../types/context";
4
7
  import type { CatladderJob } from "../types/jobs";
5
8
 
6
9
  const injectDefaultVarsInCustomJobs = (
@@ -24,7 +27,12 @@ const getCustomJobs = (context: ComponentContext) => {
24
27
  export const createJobsForComponentContext = (
25
28
  context: ComponentContext,
26
29
  ): CatladderJob[] => {
27
- const buildJobs = BUILD_TYPES[context.build.buildType].jobs(context);
30
+ const buildJobs =
31
+ context.build.type !== "disabled"
32
+ ? BUILD_TYPES[context.build.buildType].jobs(
33
+ context as ComponentContextWithBuild,
34
+ )
35
+ : [];
28
36
  const deployJobs =
29
37
  context.componentConfig.deploy !== false
30
38
  ? DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context)
@@ -83,7 +83,7 @@ export type DefaultEnvConfig = {
83
83
  /**
84
84
  * how the app is built and its runtime
85
85
  */
86
- build: BuildConfig;
86
+ build: BuildConfig | false;
87
87
  /**
88
88
  * environment variables
89
89
  */
@@ -116,6 +116,9 @@ export type BuildContextStandalone<
116
116
  buildType: C["type"];
117
117
  };
118
118
 
119
+ export type BuildContextDisabled = BuildContextComponentBase & {
120
+ type: "disabled";
121
+ };
119
122
  export type BuildContextFromWorkspace = BuildContextComponentBase & {
120
123
  config: BuildConfigFromWorkspace;
121
124
  workspaceName: string;
@@ -133,10 +136,14 @@ export type BuildContextWorkspace = BuildContextBase & {
133
136
  config: WorkspaceBuildConfig;
134
137
  };
135
138
 
136
- export type BuildContextComponent =
139
+ export type BuildContextWithBuild =
137
140
  | BuildContextStandalone
138
141
  | BuildContextFromWorkspace;
139
142
 
143
+ export type BuildContextComponent =
144
+ | BuildContextWithBuild
145
+ | BuildContextDisabled;
146
+
140
147
  export type BuildContext = BuildContextComponent | BuildContextWorkspace;
141
148
 
142
149
  export type DeployContext = {
@@ -172,6 +179,8 @@ export type ComponentContext<
172
179
  customJobs?: CatladderJob[];
173
180
  };
174
181
 
182
+ export type ComponentContextWithBuild = ComponentContext<BuildContextWithBuild>;
183
+
175
184
  export type Context = ComponentContext | WorkspaceContext;
176
185
 
177
186
  export type CatladderJobWithContext<S = BaseStage> = CatladderJob<S> & {