@catladder/pipeline 0.0.0-refactor-docker-9fda97e9 → 0.0.0-refactor-docker-c24f8608

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 (169) hide show
  1. package/dist/build/base/createAppBuildJob.d.ts +2 -2
  2. package/dist/build/base/createAppBuildJob.js +1 -1
  3. package/dist/build/base/index.d.ts +2 -2
  4. package/dist/build/base/writeBuildInfo.d.ts +2 -2
  5. package/dist/build/base/writeDotEnv.d.ts +2 -2
  6. package/dist/build/custom/buildJob.d.ts +2 -2
  7. package/dist/build/custom/index.d.ts +2 -2
  8. package/dist/build/custom/testJob.d.ts +2 -2
  9. package/dist/build/docker.d.ts +11 -11
  10. package/dist/build/docker.js +6 -6
  11. package/dist/build/index.d.ts +2 -2
  12. package/dist/build/node/buildJob.d.ts +2 -2
  13. package/dist/build/node/buildJob.js +7 -7
  14. package/dist/build/node/cache.d.ts +5 -5
  15. package/dist/build/node/cache.js +4 -4
  16. package/dist/build/node/index.d.ts +4 -4
  17. package/dist/build/node/meteor.d.ts +2 -2
  18. package/dist/build/node/meteor.js +2 -2
  19. package/dist/build/node/testJob.d.ts +2 -2
  20. package/dist/build/node/testJob.js +6 -6
  21. package/dist/build/node/yarn.d.ts +4 -4
  22. package/dist/build/node/yarn.js +1 -1
  23. package/dist/build/rails/build.d.ts +2 -2
  24. package/dist/build/rails/index.d.ts +2 -2
  25. package/dist/build/rails/test.d.ts +2 -2
  26. package/dist/build/sbom.d.ts +2 -2
  27. package/dist/build/sbom.js +1 -1
  28. package/dist/bundles/catladder-gitlab/index.js +61 -46
  29. package/dist/constants.js +1 -1
  30. package/dist/context/getEnvironment.d.ts +2 -2
  31. package/dist/context/getEnvironmentContext.d.ts +2 -2
  32. package/dist/context/getEnvironmentVariables.d.ts +4 -4
  33. package/dist/context/getEnvironmentVariables.js +1 -2
  34. package/dist/context/getLabels.d.ts +2 -2
  35. package/dist/context/index.d.ts +7 -3
  36. package/dist/context/index.js +12 -3
  37. package/dist/deploy/base/deploy.d.ts +2 -2
  38. package/dist/deploy/base/index.d.ts +2 -2
  39. package/dist/deploy/base/rollback.d.ts +2 -2
  40. package/dist/deploy/base/stop.d.ts +2 -2
  41. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -7
  42. package/dist/deploy/cloudRun/cleanup.d.ts +2 -2
  43. package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -2
  44. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +6 -6
  45. package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +3 -3
  46. package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
  47. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.d.ts +2 -2
  48. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +1 -2
  49. package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.d.ts +2 -2
  50. package/dist/deploy/cloudRun/createJobs/index.d.ts +2 -2
  51. package/dist/deploy/cloudRun/utils/database.d.ts +3 -3
  52. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -2
  53. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -2
  54. package/dist/deploy/custom/deployJob.d.ts +2 -2
  55. package/dist/deploy/custom/deployJob.js +1 -1
  56. package/dist/deploy/dockerTag/deployJob.d.ts +2 -2
  57. package/dist/deploy/index.d.ts +2 -2
  58. package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -3
  59. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  60. package/dist/deploy/kubernetes/kubeEnv.d.ts +2 -2
  61. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  62. package/dist/deploy/kubernetes/kubeValues.js +1 -3
  63. package/dist/deploy/kubernetes/mongodb.d.ts +2 -2
  64. package/dist/deploy/sbom.d.ts +4 -4
  65. package/dist/deploy/utils.d.ts +2 -2
  66. package/dist/pipeline/createJobsForComponent.d.ts +2 -2
  67. package/dist/pipeline/createJobsForComponent.js +1 -1
  68. package/dist/pipeline/generatePipelineFiles.js +15 -5
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/dist/types/config.d.ts +3 -3
  71. package/dist/types/context.d.ts +16 -2
  72. package/dist/types/jobs.d.ts +1 -1
  73. package/examples/__snapshots__/cloud-run-storybook.ts.snap +1687 -0
  74. package/examples/__utils__/helpers.ts +2 -2
  75. package/examples/cloud-run-storybook.ts +24 -0
  76. package/package.json +1 -1
  77. package/scripts/generate-gitlab-ci-types.ts +2 -2
  78. package/src/bash/BashExpression.ts +4 -4
  79. package/src/bash/bashExpressionPerPipelineType.ts +1 -1
  80. package/src/bash/replaceAsync.ts +4 -4
  81. package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
  82. package/src/build/base/createAppBuildJob.ts +3 -3
  83. package/src/build/base/createArtifactsConfig.ts +2 -2
  84. package/src/build/base/index.ts +2 -2
  85. package/src/build/base/writeBuildInfo.ts +2 -2
  86. package/src/build/base/writeDotEnv.ts +3 -3
  87. package/src/build/custom/__tests__/testJob.test.ts +6 -6
  88. package/src/build/custom/buildJob.ts +4 -2
  89. package/src/build/custom/index.ts +2 -2
  90. package/src/build/custom/testJob.ts +7 -5
  91. package/src/build/docker.ts +18 -18
  92. package/src/build/index.ts +3 -3
  93. package/src/build/node/buildJob.ts +16 -10
  94. package/src/build/node/cache.ts +13 -13
  95. package/src/build/node/index.ts +6 -4
  96. package/src/build/node/meteor.ts +10 -5
  97. package/src/build/node/testJob.ts +14 -11
  98. package/src/build/node/yarn.ts +13 -15
  99. package/src/build/rails/build.ts +4 -2
  100. package/src/build/rails/index.ts +2 -2
  101. package/src/build/rails/test.ts +4 -2
  102. package/src/build/sbom.ts +4 -4
  103. package/src/config/configruedEnvs.ts +6 -6
  104. package/src/config/readConfig.ts +2 -2
  105. package/src/context/__tests__/resolveReferences.test.ts +1 -1
  106. package/src/context/getBuildInfoVariables.ts +5 -5
  107. package/src/context/getEnvConfig.ts +1 -1
  108. package/src/context/getEnvType.ts +1 -1
  109. package/src/context/getEnvironment.ts +2 -2
  110. package/src/context/getEnvironmentContext.ts +4 -4
  111. package/src/context/getEnvironmentVariables.ts +19 -16
  112. package/src/context/getLabels.ts +2 -2
  113. package/src/context/getReviewSlug.ts +2 -2
  114. package/src/context/index.ts +17 -7
  115. package/src/context/resolveReferences.ts +12 -9
  116. package/src/context/transformJobOnlyVars.ts +1 -1
  117. package/src/context/utils/envVars.ts +3 -3
  118. package/src/deploy/base/deploy.ts +7 -7
  119. package/src/deploy/base/index.ts +3 -3
  120. package/src/deploy/base/rollback.ts +3 -3
  121. package/src/deploy/base/stop.ts +3 -3
  122. package/src/deploy/cloudRun/artifactsRegistry.ts +17 -12
  123. package/src/deploy/cloudRun/cleanup.ts +5 -5
  124. package/src/deploy/cloudRun/cloudRunRevisions.ts +6 -6
  125. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +20 -20
  126. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -7
  127. package/src/deploy/cloudRun/createJobs/common.ts +5 -5
  128. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +12 -9
  129. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +3 -3
  130. package/src/deploy/cloudRun/createJobs/index.ts +2 -2
  131. package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
  132. package/src/deploy/cloudRun/index.ts +10 -6
  133. package/src/deploy/cloudRun/utils/createArgsString.ts +1 -1
  134. package/src/deploy/cloudRun/utils/database.ts +8 -8
  135. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +5 -3
  136. package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
  137. package/src/deploy/cloudRun/utils/jobName.ts +1 -1
  138. package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
  139. package/src/deploy/cloudSql/utils.ts +2 -2
  140. package/src/deploy/custom/deployJob.ts +7 -3
  141. package/src/deploy/dockerTag/deployJob.ts +4 -2
  142. package/src/deploy/index.ts +5 -5
  143. package/src/deploy/kubernetes/cloudSql/index.ts +5 -5
  144. package/src/deploy/kubernetes/deployJob.ts +7 -7
  145. package/src/deploy/kubernetes/index.ts +1 -1
  146. package/src/deploy/kubernetes/kubeEnv.ts +3 -3
  147. package/src/deploy/kubernetes/kubeValues.ts +8 -8
  148. package/src/deploy/kubernetes/mongodb.ts +9 -9
  149. package/src/deploy/kubernetes/processSecretsAsFiles.ts +3 -3
  150. package/src/deploy/sbom.ts +8 -4
  151. package/src/deploy/utils.ts +4 -4
  152. package/src/pipeline/createAllJobs.ts +4 -4
  153. package/src/pipeline/createChildPipeline.ts +2 -2
  154. package/src/pipeline/createJobsForComponent.ts +13 -9
  155. package/src/pipeline/createMainPipeline.ts +20 -17
  156. package/src/pipeline/generatePipelineFiles.ts +21 -12
  157. package/src/pipeline/getPipelineStages.ts +1 -1
  158. package/src/pipeline/gitlab/createGitlabJobs.ts +26 -26
  159. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +6 -6
  160. package/src/pipeline/packageManager.ts +2 -2
  161. package/src/pipeline/yarn/yarnUtils.ts +7 -7
  162. package/src/types/config.ts +4 -4
  163. package/src/types/context.ts +19 -3
  164. package/src/types/environmentContext.ts +1 -1
  165. package/src/types/jobs.ts +1 -1
  166. package/src/types/utils.ts +4 -4
  167. package/src/utils/gitlab.ts +1 -1
  168. package/src/utils/index.ts +2 -2
  169. package/src/utils/writeFiles.ts +2 -2
@@ -1,5 +1,8 @@
1
1
  import { isNil, omit } from "lodash";
2
- import type { Context, UnspecifiedEnvVars } from "../../../types/context";
2
+ import type {
3
+ ComponentContext,
4
+ UnspecifiedEnvVars,
5
+ } from "../../../types/context";
3
6
  import { collapseableSection } from "../../../utils/gitlab";
4
7
  import { getDependencyTrackUploadScript } from "../../sbom";
5
8
 
@@ -25,29 +28,29 @@ import {
25
28
  yamlBashString,
26
29
  } from "../../../bash/bashYaml";
27
30
 
28
- export function getCloudRunDeployScripts(context: Context) {
31
+ export function getCloudRunDeployScripts(context: ComponentContext) {
29
32
  const deployConfig = getCloudRunDeployConfig(context);
30
33
  const allEnvVars = omit(
31
34
  context.environment.envVars,
32
- GCLOUD_DEPLOY_CREDENTIALS_KEY
35
+ GCLOUD_DEPLOY_CREDENTIALS_KEY,
33
36
  );
34
37
 
35
38
  return [
36
39
  ...collapseableSection(
37
40
  "prepare",
38
- "Prepare..."
41
+ "Prepare...",
39
42
  )([
40
43
  ...gcloudServiceAccountLoginCommands(context),
41
44
  ...setGoogleProjectNumberScript(deployConfig),
42
45
  ]),
43
46
  ...collapseableSection(
44
47
  "writeenvvars",
45
- "Write env vars to file"
48
+ "Write env vars to file",
46
49
  )(writeBashYamlToFileScript(allEnvVars, ENV_VARS_FILENAME)),
47
50
 
48
51
  ...collapseableSection(
49
52
  "deploy",
50
- "Deploy to cloud run"
53
+ "Deploy to cloud run",
51
54
  )([
52
55
  ...(deployConfig.cloudSql
53
56
  ? getDatabaseCreateScript(context, deployConfig) // we create the db, so that we can also delete it afterwards
@@ -61,15 +64,15 @@ export function getCloudRunDeployScripts(context: Context) {
61
64
  : []),
62
65
  ...Object.entries(deployConfig.additionalServices ?? {}).map(
63
66
  ([name, service]) =>
64
- getServiceDeployScript(context, service, "-" + name)
67
+ getServiceDeployScript(context, service, "-" + name),
65
68
  ),
66
69
  ...getJobRunScripts(context, "postDeploy"),
67
70
  ]),
68
71
  ...collapseableSection(
69
72
  "cleanup",
70
- "Cleanup"
73
+ "Cleanup",
71
74
  )(
72
- getRemoveOldRevisionsAndImagesCommand(context, "postDeploy") // we cleanup inactive images both on deploy and stop
75
+ getRemoveOldRevisionsAndImagesCommand(context, "postDeploy"), // we cleanup inactive images both on deploy and stop
73
76
  ),
74
77
  ...getDependencyTrackUploadScript(context),
75
78
  ];
@@ -1,4 +1,4 @@
1
- import type { Context } from "../../../types/context";
1
+ import type { ComponentContext } from "../../../types/context";
2
2
  import { getDependencyTrackDeleteScript } from "../../sbom";
3
3
 
4
4
  import { getRemoveOldRevisionsAndImagesCommand } from "../cleanup";
@@ -12,14 +12,14 @@ import {
12
12
  import { getServiceDeleteScript } from "./cloudRunServices";
13
13
  import { getCloudRunDeployConfig } from "./common";
14
14
 
15
- export function getCloudRunStopScripts(context: Context) {
15
+ export function getCloudRunStopScripts(context: ComponentContext) {
16
16
  const deployConfig = getCloudRunDeployConfig(context);
17
17
  return [
18
18
  ...gcloudServiceAccountLoginCommands(context),
19
19
  ...getJobRunScripts(context, "preStop"),
20
20
  ...(deployConfig.service !== false ? getServiceDeleteScript(context) : []),
21
21
  ...Object.entries(deployConfig.additionalServices ?? {}).flatMap(([name]) =>
22
- getServiceDeleteScript(context, name)
22
+ getServiceDeleteScript(context, name),
23
23
  ),
24
24
  ...getJobRunScripts(context, "postStop"),
25
25
  ...getDeleteSchedulesScripts(context),
@@ -1,5 +1,5 @@
1
1
  import { getRunnerImage } from "../../../runner";
2
- import type { Context } from "../../../types/context";
2
+ import type { ComponentContext } from "../../../types/context";
3
3
  import type { CatladderJob } from "../../../types/jobs";
4
4
  import { allowFailureInScripts } from "../../../utils/gitlab";
5
5
  import { createDeployementJobs } from "../../base";
@@ -10,7 +10,7 @@ import { getCloudRunDeployScripts } from "./getCloudRunDeployScripts";
10
10
  import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
11
11
 
12
12
  export const createGoogleCloudRunDeployJobs = (
13
- context: Context
13
+ context: ComponentContext,
14
14
  ): CatladderJob[] => {
15
15
  const deployConfig = context.componentConfig.deploy;
16
16
  if (deployConfig === false) {
@@ -3,7 +3,7 @@ import type { keyValuesArg } from "../utils/createArgsString";
3
3
 
4
4
  export const createVolumeConfig = (
5
5
  volumes: DeployConfigCloudRunVolumes | undefined,
6
- type: "service" | "job"
6
+ type: "service" | "job",
7
7
  ): keyValuesArg[] => {
8
8
  if (!volumes) {
9
9
  return [];
@@ -16,7 +16,7 @@ export const createVolumeConfig = (
16
16
  readonly ? ",readonly=true" : ""
17
17
  }`,
18
18
  "add-volume-mount": `volume=${volumeName},mount-path=${mountPath}`,
19
- })
19
+ }),
20
20
  ),
21
21
  type === "service" ? { "execution-environment": "gen2" } : {},
22
22
  ];
@@ -33,11 +33,11 @@ const getCloudSqlVariables = ({
33
33
  deployConfigRaw.cloudSql,
34
34
  fullConfig,
35
35
  environmentSlugPrefix,
36
- componentName
36
+ componentName,
37
37
  );
38
38
 
39
39
  const additionalQueryParamsString = Object.entries(
40
- deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {}
40
+ deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {},
41
41
  )
42
42
  .map(([key, value]) => `&${key}=${value}`)
43
43
  .join("");
@@ -49,7 +49,7 @@ const getCloudSqlVariables = ({
49
49
  DB_USER: deployConfigRaw.cloudSql.dbUser ?? "postgres",
50
50
  DB_PASSWORD: "$" + getSecretVarName(env, componentName, "DB_PASSWORD"),
51
51
  DATABASE_URL: `${getDatabaseConnectionString(
52
- deployConfigRaw.cloudSql
52
+ deployConfigRaw.cloudSql,
53
53
  )}${additionalQueryParamsString}`,
54
54
  DATABASE_JDBC_URL: DATABASE_JDBC_URL,
55
55
  };
@@ -88,10 +88,14 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
88
88
  [
89
89
  fullName,
90
90
  getBashVariable(
91
- getSecretVarName(env, componentName, GCLOUD_RUN_CANONICAL_HOST_SUFFIX)
91
+ getSecretVarName(
92
+ env,
93
+ componentName,
94
+ GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
95
+ ),
92
96
  ),
93
97
  ],
94
- "-"
98
+ "-",
95
99
  ).toLowerCase();
96
100
  const jobTriggers =
97
101
  deployConfigRaw && deployConfigRaw.jobs
@@ -103,7 +107,7 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
103
107
  }-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${
104
108
  deployConfigRaw.projectId
105
109
  }/jobs/${getCloudRunJobName(fullName, name)}:run`,
106
- ])
110
+ ]),
107
111
  )
108
112
  : {};
109
113
 
@@ -23,7 +23,7 @@ export const createArgsString = (...args: keyValuesArg[]) =>
23
23
  return `--no-${key}`;
24
24
  }
25
25
  return `--${key}=${value}`;
26
- })
26
+ }),
27
27
  )
28
28
  .flat()
29
29
  .join(" ");
@@ -1,4 +1,4 @@
1
- import type { Context } from "../../../types";
1
+ import type { ComponentContext } from "../../../types";
2
2
  import { allowFailureInScripts, repeatOnFailure } from "../../../utils/gitlab";
3
3
  import type {
4
4
  DeployConfigCloudRun,
@@ -6,8 +6,8 @@ import type {
6
6
  } from "../../types";
7
7
 
8
8
  export const getDatabaseDeleteScript = (
9
- context: Context,
10
- deployConfig: DeployConfigCloudRun
9
+ context: ComponentContext,
10
+ deployConfig: DeployConfigCloudRun,
11
11
  ): string[] => {
12
12
  if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
13
13
  throw new Error("not possible");
@@ -29,14 +29,14 @@ export const getDatabaseDeleteScript = (
29
29
  `gcloud sql databases delete ${DB_NAME} --instance=${instanceId} --project ${projectId}`,
30
30
  {
31
31
  pauseInSeconds: 10,
32
- }
32
+ },
33
33
  ),
34
34
  ];
35
35
  };
36
36
 
37
37
  export const getDatabaseCreateScript = (
38
- context: Context,
39
- deployConfig: DeployConfigCloudRun
38
+ context: ComponentContext,
39
+ deployConfig: DeployConfigCloudRun,
40
40
  ): string[] => {
41
41
  if (!deployConfig.cloudSql) {
42
42
  throw new Error("not possible");
@@ -61,14 +61,14 @@ export const DATABASE_JDBC_URL =
61
61
  "jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD";
62
62
 
63
63
  export const getDatabaseConnectionString = (
64
- config: DeployConfigCloudRunCloudSql
64
+ config: DeployConfigCloudRunCloudSql,
65
65
  ): string => {
66
66
  switch (config.dbConnectionStringFormat) {
67
67
  case "jdbc":
68
68
  return DATABASE_JDBC_URL;
69
69
  case "rails":
70
70
  return `postgresql://$DB_USER:$DB_PASSWORD@${encodeURIComponent(
71
- `/cloudsql/${config.instanceConnectionName}`
71
+ `/cloudsql/${config.instanceConnectionName}`,
72
72
  )}/$DB_NAME?`;
73
73
  default:
74
74
  // prisma
@@ -1,10 +1,12 @@
1
1
  import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from "..";
2
2
  import { getSecretVarNameForContext } from "../../../context";
3
- import type { Context } from "../../../types";
3
+ import type { ComponentContext } from "../../../types";
4
4
 
5
- export const gcloudServiceAccountLoginCommands = (context: Context) => [
5
+ export const gcloudServiceAccountLoginCommands = (
6
+ context: ComponentContext,
7
+ ) => [
6
8
  `gcloud auth activate-service-account --key-file=<(echo "$${getSecretVarNameForContext(
7
9
  context,
8
- GCLOUD_DEPLOY_CREDENTIALS_KEY
10
+ GCLOUD_DEPLOY_CREDENTIALS_KEY,
9
11
  )}")`,
10
12
  ];
@@ -1,3 +1,3 @@
1
- import type { Context } from "../../../types/context";
2
- export const getServiceName = (context: Context) =>
1
+ import type { ComponentContext } from "../../../types/context";
2
+ export const getServiceName = (context: ComponentContext) =>
3
3
  context.environment.fullName.toLowerCase();
@@ -2,6 +2,6 @@ import type { StringOrBashExpression } from "../../../bash/BashExpression";
2
2
 
3
3
  export const getCloudRunJobName = (
4
4
  fullAppName: StringOrBashExpression,
5
- jobName: string
5
+ jobName: string,
6
6
  ): StringOrBashExpression =>
7
7
  fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
@@ -8,5 +8,5 @@
8
8
  */
9
9
  export const removeFirstLinesFromCommandOutput = (
10
10
  cmd: string,
11
- removeFirstN: number
11
+ removeFirstN: number,
12
12
  ) => (removeFirstN === 0 ? cmd : `${cmd} | tail -n +${removeFirstN + 1}`);
@@ -12,7 +12,7 @@ export const getFullDbName = (
12
12
  | DeployConfigKubernetesValuesCloudSQLUnmanaged,
13
13
  fullConfig: Config<never>,
14
14
  environmentSlugPrefix: StringOrBashExpression,
15
- componentName: string
15
+ componentName: string,
16
16
  ) => {
17
17
  return joinBashExpressions(
18
18
  [
@@ -21,6 +21,6 @@ export const getFullDbName = (
21
21
  environmentSlugPrefix,
22
22
  cloudSqlConfig.dbBaseName ?? componentName,
23
23
  ].flatMap((part) => (part ? [part] : [])),
24
- "-"
24
+ "-",
25
25
  );
26
26
  };
@@ -1,6 +1,6 @@
1
1
  import { getYarnInstall } from "../../build/node/yarn";
2
2
  import { getRunnerImage } from "../../runner";
3
- import type { Context } from "../../types/context";
3
+ import type { ComponentContext } from "../../types/context";
4
4
  import type { CatladderJob } from "../../types/jobs";
5
5
  import { createDeployementJobs } from "../base";
6
6
  import {
@@ -9,7 +9,9 @@ import {
9
9
  } from "../sbom";
10
10
  import { isOfDeployType } from "../types";
11
11
 
12
- export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
12
+ export const createCustomDeployJobs = (
13
+ context: ComponentContext,
14
+ ): CatladderJob[] => {
13
15
  const deployConfig = context.componentConfig.deploy;
14
16
  if (deployConfig === false) {
15
17
  return [];
@@ -19,7 +21,9 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
19
21
  throw new Error("deploy config is not custom");
20
22
  }
21
23
  // FIXME: custom deploy currently assumes yarn-based project
22
- const yarnInstall = getYarnInstall(context, { noCustomPostInstall: true });
24
+ const yarnInstall = getYarnInstall(context.buildContext, {
25
+ noCustomPostInstall: true,
26
+ });
23
27
  return createDeployementJobs(context, {
24
28
  deploy: {
25
29
  image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
@@ -1,11 +1,13 @@
1
1
  import { getDockerJobBaseProps, gitlabDockerLogin } from "../../build/docker";
2
2
 
3
- import type { Context } from "../../types/context";
3
+ import type { ComponentContext } from "../../types/context";
4
4
  import type { CatladderJob } from "../../types/jobs";
5
5
  import { createDeployementJobs } from "../base";
6
6
  import { isOfDeployType } from "../types";
7
7
 
8
- export const createDockerTagDeployJobs = (context: Context): CatladderJob[] => {
8
+ export const createDockerTagDeployJobs = (
9
+ context: ComponentContext,
10
+ ): CatladderJob[] => {
9
11
  const deployConfig = context.componentConfig.deploy;
10
12
  if (deployConfig === false) {
11
13
  return [];
@@ -1,6 +1,6 @@
1
1
  import type { SecretEnvVar } from "..";
2
2
  import type { BashExpression } from "../bash/BashExpression";
3
- import type { Context } from "../types/context";
3
+ import type { ComponentContext } from "../types/context";
4
4
  import type { EnvironmentContext } from "../types/environmentContext";
5
5
  import type { CatladderJob } from "../types/jobs";
6
6
  import type { PartialDeep } from "../types/utils";
@@ -15,15 +15,15 @@ export * from "./types";
15
15
  export * from "./utils";
16
16
 
17
17
  export type DeployTypeDefinition<T extends DeployConfigType> = {
18
- jobs: (context: Context) => CatladderJob[];
18
+ jobs: (context: ComponentContext) => CatladderJob[];
19
19
  defaults: (
20
- envContext: EnvironmentContext<any, T>
20
+ envContext: EnvironmentContext<any, T>,
21
21
  ) => PartialDeep<DeployConfigGeneric<T>>;
22
22
  additionalSecretKeys: (
23
- envContext: EnvironmentContext<any, T>
23
+ envContext: EnvironmentContext<any, T>,
24
24
  ) => SecretEnvVar[];
25
25
  getAdditionalEnvVars: (
26
- envContext: EnvironmentContext<any, T>
26
+ envContext: EnvironmentContext<any, T>,
27
27
  ) => Record<string, string | BashExpression | undefined | null>;
28
28
  };
29
29
  export type DeployTypes = {
@@ -1,10 +1,10 @@
1
1
  import type { StringOrBashExpression } from "../../../bash/BashExpression";
2
2
  import { getSecretVarNameForContext } from "../../../context";
3
- import type { Context } from "../../../types";
3
+ import type { ComponentContext } from "../../../types";
4
4
  import { getFullDbName } from "../../cloudSql/utils";
5
5
  import { isOfDeployType } from "../../types";
6
6
 
7
- export const hasKubernetesCloudSQL = (context: Context) => {
7
+ export const hasKubernetesCloudSQL = (context: ComponentContext) => {
8
8
  if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
9
9
  return context.componentConfig.deploy.values?.cloudsql?.enabled;
10
10
  }
@@ -20,7 +20,7 @@ type CloudSqlValues = {
20
20
  dbUser: string;
21
21
  };
22
22
  export const createKubernetesCloudsqlBaseValues = (
23
- context: Context
23
+ context: ComponentContext,
24
24
  ): {
25
25
  cloudsql: CloudSqlValues;
26
26
  } => {
@@ -36,7 +36,7 @@ export const createKubernetesCloudsqlBaseValues = (
36
36
 
37
37
  const proxyCredentials = `$${getSecretVarNameForContext(
38
38
  context,
39
- "cloudsqlProxyCredentials"
39
+ "cloudsqlProxyCredentials",
40
40
  )}`;
41
41
  if (config?.type !== "unmanaged") {
42
42
  const instanceConnectionName = `${config.projectId ?? "skynet-164509"}:${
@@ -63,7 +63,7 @@ export const createKubernetesCloudsqlBaseValues = (
63
63
  config,
64
64
  context.fullConfig,
65
65
  context.environment.slugPrefix,
66
- context.componentName
66
+ context.componentName,
67
67
  ),
68
68
  },
69
69
  };
@@ -1,6 +1,6 @@
1
1
  import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
2
2
  import { getRunnerImage } from "../../runner";
3
- import type { Context } from "../../types/context";
3
+ import type { ComponentContext } from "../../types/context";
4
4
  import type { CatladderJob } from "../../types/jobs";
5
5
  import { createDeployementJobs } from "../base";
6
6
  import {
@@ -15,7 +15,7 @@ import { collapseableSection } from "../../utils/gitlab";
15
15
 
16
16
  const ALL_VALUES_FILE = "__all_values.yml";
17
17
  export const createKubernetesDeployJobs = (
18
- context: Context
18
+ context: ComponentContext,
19
19
  ): CatladderJob[] => {
20
20
  const deployConfig = context.componentConfig.deploy;
21
21
  if (deployConfig === false) {
@@ -59,14 +59,14 @@ export const createKubernetesDeployJobs = (
59
59
  const connectContext = [
60
60
  `kubectl config set-cluster "${clusterName}" --server="$${getSecretVarNameForContext(
61
61
  context,
62
- "KUBE_URL"
62
+ "KUBE_URL",
63
63
  )}" --certificate-authority <(echo $${getSecretVarNameForContext(
64
64
  context,
65
- "KUBE_CA_PEM"
65
+ "KUBE_CA_PEM",
66
66
  )} | base64 -d) --embed-certs=true`,
67
67
  `kubectl config set-credentials "${clusterName}" --token="$${getSecretVarNameForContext(
68
68
  context,
69
- "KUBE_TOKEN"
69
+ "KUBE_TOKEN",
70
70
  )}"`,
71
71
  `kubectl config set-context "${clusterName}" --cluster="${clusterName}" --user="${clusterName}" --namespace="${context.environment.envVars.KUBE_NAMESPACE}"`,
72
72
  `kubectl config use-context "${clusterName}"`,
@@ -79,9 +79,9 @@ export const createKubernetesDeployJobs = (
79
79
  ...connectContext,
80
80
  ...collapseableSection(
81
81
  "writeallvalues",
82
- "Write " + ALL_VALUES_FILE + " for helm deployment"
82
+ "Write " + ALL_VALUES_FILE + " for helm deployment",
83
83
  )(
84
- writeBashYamlToFileScript(createKubeValues(context), ALL_VALUES_FILE)
84
+ writeBashYamlToFileScript(createKubeValues(context), ALL_VALUES_FILE),
85
85
  ),
86
86
  "kubernetesCreateSecret",
87
87
  "kubernetesDeploy",
@@ -37,7 +37,7 @@ export const KUBERNETES_DEPLOY_TYPE: DeployTypeDefinition<"kubernetes"> = {
37
37
  fullConfig.customerName,
38
38
  domainCanonical,
39
39
  ],
40
- "."
40
+ ".",
41
41
  ); // default for kubernetes and rest
42
42
  return {
43
43
  KUBE_NAMESPACE,
@@ -1,5 +1,5 @@
1
1
  import type { StringOrBashExpression } from "../../bash/BashExpression";
2
- import type { Context } from "../../types";
2
+ import type { ComponentContext } from "../../types";
3
3
  import { isOfDeployType } from "../types";
4
4
 
5
5
  const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
@@ -14,7 +14,7 @@ const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
14
14
  * separate by secrets and public.
15
15
  * we evalulate the actual values later, but want to store the secrets in kubernetes secrets
16
16
  */
17
- export const createKubeEnv = (context: Context) => {
17
+ export const createKubeEnv = (context: ComponentContext) => {
18
18
  if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
19
19
  // should not happen
20
20
  throw new Error("deploy config is not kubernetes");
@@ -43,7 +43,7 @@ export const createKubeEnv = (context: Context) => {
43
43
  {
44
44
  secret: {},
45
45
  public: {},
46
- }
46
+ },
47
47
  );
48
48
 
49
49
  return env;
@@ -1,6 +1,6 @@
1
1
  import { merge } from "lodash";
2
2
 
3
- import type { Context } from "../../types/context";
3
+ import type { ComponentContext } from "../../types/context";
4
4
  import { mergeWithMergingArrays } from "../../utils";
5
5
  import type { DeployConfigKubernetesValues } from "../types";
6
6
  import { isOfDeployType } from "../types";
@@ -14,8 +14,8 @@ import { createMongodbBaseConfig } from "./mongodb";
14
14
  import { processSecretsAsFiles } from "./processSecretsAsFiles";
15
15
 
16
16
  const createAppConfig = (
17
- context: Context,
18
- application: DeployConfigKubernetesValues["application"]
17
+ context: ComponentContext,
18
+ application: DeployConfigKubernetesValues["application"],
19
19
  ): DeployConfigKubernetesValues["application"] => {
20
20
  if (application === false) {
21
21
  return {
@@ -45,18 +45,18 @@ const createAppConfig = (
45
45
  },
46
46
  },
47
47
  }, // default
48
- rest // merge rest in
48
+ rest, // merge rest in
49
49
  );
50
50
  };
51
51
 
52
52
  const removeFalsy = <T>(record?: Record<string, false | T>) => {
53
53
  if (!record) return undefined;
54
54
  return Object.fromEntries(
55
- Object.entries(record).filter(([, value]) => value !== false)
55
+ Object.entries(record).filter(([, value]) => value !== false),
56
56
  );
57
57
  };
58
58
 
59
- export const createKubeValues = (context: Context) => {
59
+ export const createKubeValues = (context: ComponentContext) => {
60
60
  const deployConfig = context.componentConfig.deploy;
61
61
  if (deployConfig === false) {
62
62
  return [];
@@ -84,7 +84,7 @@ export const createKubeValues = (context: Context) => {
84
84
  : {},
85
85
  deployConfig.values?.mongodb?.enabled
86
86
  ? createMongodbBaseConfig(context)
87
- : {}
87
+ : {},
88
88
  );
89
89
 
90
90
  const kubeValues = processSecretsAsFiles(
@@ -93,7 +93,7 @@ export const createKubeValues = (context: Context) => {
93
93
  cronjobs: removeFalsy(cronjobs),
94
94
 
95
95
  ...rest,
96
- })
96
+ }),
97
97
  );
98
98
 
99
99
  return kubeValues;
@@ -1,28 +1,28 @@
1
1
  import { range } from "lodash";
2
2
  import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
3
- import type { Context } from "../../types/context";
3
+ import type { ComponentContext } from "../../types/context";
4
4
  import { isOfDeployType } from "../types";
5
5
 
6
- const getCredentialString = (context: Context) =>
6
+ const getCredentialString = (context: ComponentContext) =>
7
7
  `root:$${getSecretVarNameForContext(context, "MONGODB_ROOT_PASSWORD")}@`;
8
- const getMongodbHost = (context: Context, name: string) => {
8
+ const getMongodbHost = (context: ComponentContext, name: string) => {
9
9
  const namespace = context.environment.envVars.KUBE_NAMESPACE;
10
10
  return `${name}.${namespace}.svc.cluster.local:27017`;
11
11
  };
12
12
 
13
- const getMongodbStandaloneHost = (context: Context) => {
13
+ const getMongodbStandaloneHost = (context: ComponentContext) => {
14
14
  const fullAppname = context.environment.envVars.KUBE_APP_NAME;
15
15
  return getMongodbHost(context, `${fullAppname}-mongodb`);
16
16
  };
17
17
 
18
- const getMongodbReplicasetHost = (context: Context, index: number) => {
18
+ const getMongodbReplicasetHost = (context: ComponentContext, index: number) => {
19
19
  const fullAppname = context.environment.envVars.KUBE_APP_NAME;
20
20
  return getMongodbHost(
21
21
  context,
22
- `${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless`
22
+ `${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless`,
23
23
  );
24
24
  };
25
- const createMongodbUrl = (context: Context, dbName: string) => {
25
+ const createMongodbUrl = (context: ComponentContext, dbName: string) => {
26
26
  if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
27
27
  throw new Error("can only createMongodbUrl on supported deploys");
28
28
  }
@@ -46,7 +46,7 @@ const createMongodbUrl = (context: Context, dbName: string) => {
46
46
  queryParams ? `?${queryParams}` : ""
47
47
  }`;
48
48
  };
49
- const createMongoBackupDefaultConfig = (context: Context) => {
49
+ const createMongoBackupDefaultConfig = (context: ComponentContext) => {
50
50
  if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
51
51
  throw new Error("can only create mongodb base config on supported deploys");
52
52
  }
@@ -83,7 +83,7 @@ const createMongoBackupDefaultConfig = (context: Context) => {
83
83
  volumeSnapshotClass: "snapshotclass",
84
84
  };
85
85
  };
86
- export const createMongodbBaseConfig = (context: Context) => {
86
+ export const createMongodbBaseConfig = (context: ComponentContext) => {
87
87
  if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
88
88
  throw new Error("can only create mongodb base config on supported deploys");
89
89
  }
@@ -7,9 +7,9 @@ export const processSecretsAsFiles = <
7
7
  env: {
8
8
  secret: Record<string, StringOrBashExpression>;
9
9
  };
10
- } & DeployConfigKubernetesValues
10
+ } & DeployConfigKubernetesValues,
11
11
  >(
12
- values: T
12
+ values: T,
13
13
  ): T => {
14
14
  if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
15
15
  return values;
@@ -27,7 +27,7 @@ export const processSecretsAsFiles = <
27
27
  values.secretsAsFile.map((key) => [
28
28
  key + "_content",
29
29
  values.env.secret[key],
30
- ])
30
+ ]),
31
31
  ),
32
32
  },
33
33
  },
@@ -1,11 +1,13 @@
1
- import type { Context } from "../types/context";
1
+ import type { ComponentContext } from "../types/context";
2
2
  import { SBOM_FILE } from "../build/sbom";
3
3
 
4
- export const sbomDeactivated = (context: Context) =>
4
+ export const sbomDeactivated = (context: ComponentContext) =>
5
5
  context.componentConfig.build.type === "custom" &&
6
6
  context.componentConfig.build.sbom === false;
7
7
 
8
- export const getDependencyTrackUploadScript = (context: Context): string[] => {
8
+ export const getDependencyTrackUploadScript = (
9
+ context: ComponentContext,
10
+ ): string[] => {
9
11
  return sbomDeactivated(context)
10
12
  ? []
11
13
  : [
@@ -14,7 +16,9 @@ export const getDependencyTrackUploadScript = (context: Context): string[] => {
14
16
  ];
15
17
  };
16
18
 
17
- export const getDependencyTrackDeleteScript = (context: Context): string[] => {
19
+ export const getDependencyTrackDeleteScript = (
20
+ context: ComponentContext,
21
+ ): string[] => {
18
22
  return sbomDeactivated(context)
19
23
  ? []
20
24
  : [