@catladder/pipeline 0.0.0-next-9a3feef4 → 0.0.0-next-e2e4f00a

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 (97) hide show
  1. package/dist/build/base/createAppBuildJob.js +3 -3
  2. package/dist/build/custom/testJob.js +12 -12
  3. package/dist/build/node/testJob.js +11 -11
  4. package/dist/build/rails/build.js +1 -1
  5. package/dist/build/rails/test.js +8 -8
  6. package/dist/build/types.d.ts +10 -0
  7. package/dist/bundles/catladder-gitlab/index.js +150 -71
  8. package/dist/constants.js +1 -1
  9. package/dist/context/__tests__/resolveReferences.test.js +22 -0
  10. package/dist/context/createComponentContext.js +1 -0
  11. package/dist/context/getEnvironment.js +2 -1
  12. package/dist/context/getEnvironmentVariables.d.ts +5 -2
  13. package/dist/context/getEnvironmentVariables.js +24 -17
  14. package/dist/context/resolveReferences.d.ts +4 -1
  15. package/dist/context/resolveReferences.js +16 -2
  16. package/dist/deploy/base/deploy.js +3 -3
  17. package/dist/deploy/cloudRun/index.js +2 -2
  18. package/dist/deploy/kubernetes/cloudSql/index.js +14 -3
  19. package/dist/deploy/kubernetes/deployJob.js +3 -1
  20. package/dist/deploy/kubernetes/index.js +2 -2
  21. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -1
  22. package/dist/deploy/kubernetes/kubeValues.js +3 -2
  23. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +85 -0
  24. package/dist/deploy/kubernetes/processSecretsAsFiles.js +33 -0
  25. package/dist/deploy/types/base.d.ts +6 -0
  26. package/dist/deploy/types/kubernetes.d.ts +34 -1
  27. package/dist/pipeline/gitlab/createGitlabJobs.js +5 -3
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/types/config.d.ts +8 -0
  30. package/dist/types/context.d.ts +8 -0
  31. package/dist/types/jobs.d.ts +8 -0
  32. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +52 -36
  33. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +52 -36
  34. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +52 -36
  35. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +52 -36
  36. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +52 -36
  37. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +52 -36
  38. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +52 -36
  39. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +52 -36
  40. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +52 -36
  41. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +52 -36
  42. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +52 -36
  43. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +52 -36
  44. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +104 -72
  45. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +68 -48
  46. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +52 -36
  47. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +52 -36
  48. package/examples/__snapshots__/custom-build-job.test.ts.snap +52 -36
  49. package/examples/__snapshots__/custom-deploy.test.ts.snap +32 -24
  50. package/examples/__snapshots__/custom-envs.test.ts.snap +24 -18
  51. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +52 -36
  52. package/examples/__snapshots__/git-submodule.test.ts.snap +52 -36
  53. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +96 -60
  54. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +1791 -0
  55. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +96 -60
  56. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +192 -120
  57. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +96 -60
  58. package/examples/__snapshots__/local-dot-env.test.ts.snap +52 -36
  59. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +96 -60
  60. package/examples/__snapshots__/multiline-var.test.ts.snap +148 -96
  61. package/examples/__snapshots__/native-app.test.ts.snap +100 -72
  62. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +52 -36
  63. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +52 -36
  64. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +80 -48
  65. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +80 -48
  66. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +64 -48
  67. package/examples/__snapshots__/workspace-api-www-custom-cache.test.ts.snap +104 -72
  68. package/examples/__snapshots__/workspace-api-www.test.ts.snap +104 -72
  69. package/examples/kubernetes-with-cloud-sql-legacy.test.ts +11 -0
  70. package/examples/kubernetes-with-cloud-sql-legacy.ts +35 -0
  71. package/examples/native-app.ts +6 -10
  72. package/examples/rails-k8s-with-worker.ts +1 -5
  73. package/package.json +1 -1
  74. package/src/build/base/createAppBuildJob.ts +1 -0
  75. package/src/build/custom/testJob.ts +1 -0
  76. package/src/build/node/testJob.ts +1 -0
  77. package/src/build/rails/build.ts +1 -0
  78. package/src/build/rails/test.ts +1 -0
  79. package/src/build/types.ts +13 -0
  80. package/src/context/__tests__/resolveReferences.test.ts +27 -1
  81. package/src/context/createComponentContext.ts +1 -0
  82. package/src/context/getEnvironment.ts +1 -1
  83. package/src/context/getEnvironmentVariables.ts +34 -13
  84. package/src/context/resolveReferences.ts +13 -0
  85. package/src/deploy/base/deploy.ts +1 -1
  86. package/src/deploy/cloudRun/index.ts +2 -2
  87. package/src/deploy/kubernetes/cloudSql/index.ts +15 -1
  88. package/src/deploy/kubernetes/deployJob.ts +2 -0
  89. package/src/deploy/kubernetes/index.ts +2 -2
  90. package/src/deploy/kubernetes/kubeValues.ts +8 -5
  91. package/src/deploy/kubernetes/processSecretsAsFiles.ts +35 -0
  92. package/src/deploy/types/base.ts +6 -0
  93. package/src/deploy/types/kubernetes.ts +36 -1
  94. package/src/pipeline/gitlab/createGitlabJobs.ts +4 -1
  95. package/src/types/config.ts +8 -0
  96. package/src/types/context.ts +8 -1
  97. package/src/types/jobs.ts +8 -0
@@ -0,0 +1,11 @@
1
+ import { createYamlLocalPipeline } from "./__utils__/helpers";
2
+ import config from "./kubernetes-with-cloud-sql-legacy";
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 kubernetes-with-cloud-sql-legacy local pipeline YAML", async () => {
10
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
11
+ });
@@ -0,0 +1,35 @@
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: "kubernetes",
14
+ cluster: {
15
+ name: "some-cluster-name",
16
+ region: "europe-west6",
17
+ projectId: "some-project-id",
18
+ type: "gcloud",
19
+ domainCanonical: "panter.cloud",
20
+ },
21
+ values: {
22
+ cloudsql: {
23
+ enabled: true,
24
+ },
25
+ },
26
+ },
27
+ },
28
+ },
29
+ };
30
+
31
+ export default config;
32
+
33
+ export const information = {
34
+ title: "K8s: With Cloud SQL Legacy",
35
+ };
@@ -28,11 +28,9 @@ const config: Config = {
28
28
  ],
29
29
  },
30
30
  build: {
31
- jobVars: {
32
- public: {
33
- LC_A: "L=en_US.UTF-8",
34
- LANG: "en_US.UTF-8",
35
- },
31
+ extraVars: {
32
+ LC_A: "L=en_US.UTF-8",
33
+ LANG: "en_US.UTF-8",
36
34
  },
37
35
  type: "node",
38
36
  buildCommand: [
@@ -48,11 +46,9 @@ const config: Config = {
48
46
 
49
47
  deploy: {
50
48
  type: "custom",
51
- jobVars: {
52
- public: {
53
- LC_A: "L=en_US.UTF-8",
54
- LANG: "en_US.UTF-8",
55
- },
49
+ extraVars: {
50
+ LC_A: "L=en_US.UTF-8",
51
+ LANG: "en_US.UTF-8",
56
52
  },
57
53
  requiresDocker: false,
58
54
  script: [
@@ -44,11 +44,7 @@ const config: Config = {
44
44
  domainCanonical: "panter.cloud",
45
45
  },
46
46
  values: {
47
- cloudsql: {
48
- enabled: true,
49
- type: "unmanaged",
50
- instanceConnectionName: "myproject:europe-west6:instance-name",
51
- },
47
+ cloudsql: { enabled: true, projectId: "some-project-id" },
52
48
  application: {
53
49
  // if deployed to Google Cloud Run use a gem like cloudtasker instead of a permanently running expensive worker
54
50
  worker: {
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "0.0.0-next-9a3feef4",
56
+ "version": "0.0.0-next-e2e4f00a",
57
57
  "stableVersion": "0.1.0",
58
58
  "scripts": {
59
59
  "build:tsc": "yarn tsc",
@@ -40,6 +40,7 @@ export const createAppBuildJob = (
40
40
  ? {
41
41
  ...context.environment.envVars,
42
42
  ...context.environment.jobOnlyVars.build.envVars,
43
+ ...(context.build.config.extraVars ?? {}),
43
44
  }
44
45
  : {}),
45
46
  },
@@ -31,6 +31,7 @@ export const createCustomTestJobs = (
31
31
  variables: {
32
32
  APP_PATH: context.build.dir,
33
33
  ...context.environment.jobOnlyVars.build.envVars,
34
+ ...(buildConfig.extraVars ?? {}),
34
35
  },
35
36
  runnerVariables: RUNNER_CUSTOM_TEST_VARIABLES,
36
37
  services: buildConfig.jobServices,
@@ -35,6 +35,7 @@ export const createNodeTestJobs = (
35
35
  ...(context.type === "component"
36
36
  ? {
37
37
  ...context.environment.jobOnlyVars.build.envVars,
38
+ ...(context.build.config.extraVars ?? {}),
38
39
  }
39
40
  : {}),
40
41
  },
@@ -47,6 +47,7 @@ export const createRailsBuildJobs = (
47
47
  dockerBuild: {
48
48
  variables: {
49
49
  ...context.environment.jobOnlyVars.build.envVars,
50
+ ...context.build.config.extraVars,
50
51
  },
51
52
  // custom script
52
53
  script: [
@@ -24,6 +24,7 @@ export const createRailsTestJobs = (
24
24
  const base: Omit<CatladderJob, "script" | "name"> = {
25
25
  variables: {
26
26
  ...context.environment.jobOnlyVars.build.envVars,
27
+ ...(buildConfig.extraVars ?? {}),
27
28
  },
28
29
  stage: "test",
29
30
  needs: [],
@@ -82,6 +82,12 @@ export type BuildConfigBase = {
82
82
  * Can curently not reference other variables from other components
83
83
  */
84
84
  jobVars?: EnvVars;
85
+ /**
86
+ * additional env vars for the buid jobs
87
+ *
88
+ * @deprecated use jobVars or runnerVariables
89
+ */
90
+ extraVars?: Record<string, string>;
85
91
 
86
92
  /**
87
93
  * additional vars only for the runner.
@@ -226,6 +232,13 @@ export type BuildConfigDocker =
226
232
  | BuildConfigDockerBuiltIn
227
233
  | BuildConfigDockerCustom;
228
234
 
235
+ /**
236
+ * @deprecated this type is no longer used. Use {@link BuildConfigDocker} instead.
237
+ */
238
+ export type BuildConfigCustomDocker =
239
+ | BuildConfigDockerCustom
240
+ | BuildConfigDockerBuiltInNgninx;
241
+
229
242
  export type BuildConfigCustom = Omit<
230
243
  BuildConfigBase,
231
244
  "lint" | "test" | "audit"
@@ -1,5 +1,8 @@
1
1
  import type { BashExpression } from "../../bash/BashExpression";
2
- import { resolveReferences } from "../resolveReferences";
2
+ import {
3
+ resolveReferences,
4
+ translateLegacyFromComponents,
5
+ } from "../resolveReferences";
3
6
 
4
7
  const unpackBashExpressions = (obj: Record<string, string | BashExpression>) =>
5
8
  Object.fromEntries(
@@ -120,3 +123,26 @@ describe("resolveReferences", () => {
120
123
  });
121
124
  });
122
125
  });
126
+
127
+ describe("translateLegacyFromComponents", () => {
128
+ it("translatetes the old `fromComponents` approach to ${componentName:variableName}", () => {
129
+ const fromComponents = {
130
+ api: {
131
+ API_FOO: "FOO",
132
+ API_BAR: "BAR",
133
+ },
134
+ www: {
135
+ WWW_X: "X",
136
+ WWW_Y: "Y",
137
+ },
138
+ };
139
+
140
+ const result = translateLegacyFromComponents(fromComponents);
141
+ expect(result).toEqual({
142
+ API_FOO: "${api:FOO}",
143
+ API_BAR: "${api:BAR}",
144
+ WWW_X: "${www:X}",
145
+ WWW_Y: "${www:Y}",
146
+ });
147
+ });
148
+ });
@@ -108,6 +108,7 @@ export const createComponentContext = async (
108
108
  const context: Omit<ComponentContext, "customJobs"> = {
109
109
  type: "component",
110
110
  name: ctx.componentName,
111
+ componentName: ctx.componentName,
111
112
  env: ctx.env,
112
113
  fullConfig: ctx.config,
113
114
  componentConfig,
@@ -20,7 +20,7 @@ export const getEnvironment = async (
20
20
  slugPrefix: envContext.environmentSlugPrefix,
21
21
  reviewSlug: envContext.reviewSlug,
22
22
  slug: envContext.environmentSlug,
23
-
23
+ shortName: env,
24
24
  ...variables,
25
25
  };
26
26
  };
@@ -1,3 +1,4 @@
1
+ import { merge } from "lodash";
1
2
  import { DEPLOY_TYPES } from "../deploy";
2
3
  import type {
3
4
  ComponentContext,
@@ -12,7 +13,10 @@ import { isStandaloneBuildConfig } from "../build/types";
12
13
  import type { EnvironmentContext } from "../types/environmentContext";
13
14
  import { getBuildInfoVariables } from "./getBuildInfoVariables";
14
15
  import { getEnvironmentContext } from "./getEnvironmentContext";
15
- import { resolveReferences } from "./resolveReferences";
16
+ import {
17
+ resolveReferences,
18
+ translateLegacyFromComponents,
19
+ } from "./resolveReferences";
16
20
  import { transformJobOnlyVars } from "./transformJobOnlyVars";
17
21
  import {
18
22
  makeSecretEnvVarMapping,
@@ -39,9 +43,12 @@ type BasePredefinedVariables = ReturnType<typeof getBasePredefinedVariables>;
39
43
 
40
44
  // we export so that we have later nice autocomplete
41
45
  export type PredefinedVariables = BasePredefinedVariables & {
42
- HOSTNAME?: StringOrBashExpression;
46
+ /**
47
+ * undefined in rails, Rails before 6.1 (mis)uses the `HOST` environment variable to specify the IP to bind to
48
+ */
49
+ HOST?: StringOrBashExpression;
43
50
  ROOT_URL: StringOrBashExpression;
44
- HOSTNAME_INTERNAL: StringOrBashExpression;
51
+ HOST_INTERNAL: StringOrBashExpression;
45
52
  ROOT_URL_INTERNAL: StringOrBashExpression;
46
53
  };
47
54
 
@@ -71,8 +78,12 @@ export const getEnvironmentVariables = async (
71
78
  ...basePredefinedVariables,
72
79
  ENV_SHORT: "local",
73
80
  ROOT_URL: url,
74
- HOSTNAME: host,
75
- HOSTNAME_INTERNAL: host,
81
+ // Rails before 6.1 (mis)uses the `HOST` environment variable to specify the IP to bind to
82
+ ...(isStandaloneBuildConfig(buildConfigRaw) &&
83
+ buildConfigRaw.type === "rails"
84
+ ? {}
85
+ : { HOST: host }),
86
+ HOST_INTERNAL: host,
76
87
  ROOT_URL_INTERNAL: "http://" + host,
77
88
  PORT: port.toString(),
78
89
  };
@@ -83,10 +94,10 @@ export const getEnvironmentVariables = async (
83
94
  )
84
95
  : {};
85
96
 
86
- const HOSTNAME_INTERNAL =
87
- additionalEnvVars.HOSTNAME_INTERNAL ?? "unknown-host.example.com";
97
+ const HOST_INTERNAL =
98
+ additionalEnvVars.HOST_INTERNAL ?? "unknown-host.example.com";
88
99
 
89
- host = envConfigRaw?.host ?? HOSTNAME_INTERNAL;
100
+ host = envConfigRaw?.host ?? HOST_INTERNAL;
90
101
  url = joinBashExpressions(["https://", host]);
91
102
 
92
103
  predefinedVariables = {
@@ -95,11 +106,12 @@ export const getEnvironmentVariables = async (
95
106
  ...(isStandaloneBuildConfig(buildConfigRaw) &&
96
107
  buildConfigRaw.type === "rails"
97
108
  ? {}
98
- : { HOSTNAME: host }),
109
+ : { HOST: host }),
99
110
  ROOT_URL: url,
100
- HOSTNAME_INTERNAL,
101
-
102
- ROOT_URL_INTERNAL: joinBashExpressions(["https://", HOSTNAME_INTERNAL]),
111
+ HOST_INTERNAL,
112
+ /**@deprecated */
113
+ HOST_CANONICAL: HOST_INTERNAL, // legacy alias for HOST_INTERNAL
114
+ ROOT_URL_INTERNAL: joinBashExpressions(["https://", HOST_INTERNAL]),
103
115
  ...additionalEnvVars,
104
116
  };
105
117
  }
@@ -120,8 +132,17 @@ export const getEnvironmentVariables = async (
120
132
  componentName,
121
133
  secretEnvVarKeys,
122
134
  );
135
+ // this is deprecated, we now support: $componentname:FOO
136
+ const legacyFromComponents = envConfigRaw.vars?.fromComponents ?? {};
137
+ const publicEnvVarsRawWithLegacyFromComponents = merge(
138
+ {},
139
+ translateLegacyFromComponents(legacyFromComponents),
140
+ publicEnvVarsRaw,
141
+ );
123
142
 
124
- const publicEnvVarsRawSanitized = stringifyValues(publicEnvVarsRaw);
143
+ const publicEnvVarsRawSanitized = stringifyValues(
144
+ publicEnvVarsRawWithLegacyFromComponents,
145
+ );
125
146
 
126
147
  const envVarsRaw = addIndexVar({
127
148
  ...predefinedVariables,
@@ -78,3 +78,16 @@ export const resolveReferences = async (
78
78
  ),
79
79
  ) as Record<string, BashExpression>;
80
80
  };
81
+
82
+ export const translateLegacyFromComponents = (
83
+ fromComponents: Record<string, Record<string, string>>,
84
+ ) => {
85
+ return Object.fromEntries(
86
+ Object.entries(fromComponents).flatMap(([componentName, variables]) => {
87
+ return Object.entries(variables).map(([ourName, otherName]) => [
88
+ ourName,
89
+ "${" + componentName + ":" + otherName + "}",
90
+ ]);
91
+ }),
92
+ );
93
+ };
@@ -117,7 +117,7 @@ export const createDeployJob = (
117
117
  ...context.environment.envVars,
118
118
  ...(hasDocker ? getDockerImageVariables(context) : {}),
119
119
  ...context.environment.jobOnlyVars.deploy.envVars,
120
-
120
+ ...(deployConfig ? deployConfig.extraVars ?? {} : {}),
121
121
  ...jobDefinition.variables,
122
122
  },
123
123
  runnerVariables: {
@@ -85,7 +85,7 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigCloudRun>
85
85
  getAdditionalEnvVars: (ctx) => {
86
86
  const { fullName, env, componentName, deployConfigRaw } = ctx;
87
87
 
88
- const HOSTNAME_INTERNAL = joinBashExpressions(
88
+ const HOST_INTERNAL = joinBashExpressions(
89
89
  [
90
90
  fullName,
91
91
  getBashVariable(
@@ -113,7 +113,7 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigCloudRun>
113
113
  : {};
114
114
 
115
115
  return {
116
- HOSTNAME_INTERNAL,
116
+ HOST_INTERNAL,
117
117
  ...getCloudSqlVariables(ctx),
118
118
  ...jobTriggers,
119
119
  DEPLOY_CLOUD_RUN_PROJECT_ID: deployConfigRaw
@@ -41,7 +41,21 @@ export const createKubernetesCloudsqlBaseValues = (
41
41
  context,
42
42
  "cloudsqlProxyCredentials",
43
43
  )}`;
44
- if (config.type === "unmanaged") {
44
+ if (config?.type !== "unmanaged") {
45
+ const instanceConnectionName = `${config.projectId ?? "skynet-164509"}:${
46
+ config.region ?? "europe-west6"
47
+ }:${config.instanceId ?? context.environment.envVars.KUBE_NAMESPACE}`;
48
+
49
+ return {
50
+ cloudsql: {
51
+ enabled: config.enabled,
52
+ dbUser: "postgres",
53
+ instanceConnectionName,
54
+ proxyCredentials,
55
+ fullDbName: context.environment.envVars.KUBE_APP_NAME ?? "",
56
+ },
57
+ };
58
+ } else if (config.type === "unmanaged") {
45
59
  return {
46
60
  cloudsql: {
47
61
  enabled: config.enabled,
@@ -47,6 +47,8 @@ export const createKubernetesDeployJobs = (
47
47
  ...(deployConfig.additionalHelmArgs ?? []),
48
48
  ].join(" "),
49
49
  COMPONENT_NAME: context.name,
50
+ /** @deprecated */
51
+ BUILD_ID: context.environment.envVars.BUILD_INFO_BUILD_ID,
50
52
  },
51
53
  };
52
54
 
@@ -29,7 +29,7 @@ export const KUBERNETES_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigKubernetes
29
29
  fullConfig.domainCanonical ||
30
30
  "panter.cloud";
31
31
 
32
- const HOSTNAME_INTERNAL = joinBashExpressions(
32
+ const HOST_INTERNAL = joinBashExpressions(
33
33
  [
34
34
  componentSlug,
35
35
  ...(envType === "review" && reviewSlug ? [reviewSlug] : []),
@@ -44,7 +44,7 @@ export const KUBERNETES_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigKubernetes
44
44
  KUBE_NAMESPACE,
45
45
  KUBE_APP_NAME,
46
46
  KUBE_APP_NAME_PREFIX,
47
- HOSTNAME_INTERNAL,
47
+ HOST_INTERNAL,
48
48
  };
49
49
  },
50
50
  };
@@ -11,6 +11,7 @@ import {
11
11
 
12
12
  import { createKubeEnv } from "./kubeEnv";
13
13
  import { createMongodbBaseConfig } from "./mongodb";
14
+ import { processSecretsAsFiles } from "./processSecretsAsFiles";
14
15
 
15
16
  const createAppConfig = (
16
17
  context: ComponentContext,
@@ -86,12 +87,14 @@ export const createKubeValues = (context: ComponentContext) => {
86
87
  : {},
87
88
  );
88
89
 
89
- const kubeValues = mergeWithMergingArrays(defaultKubeValues, {
90
- jobs: removeFalsy(jobs),
91
- cronjobs: removeFalsy(cronjobs),
90
+ const kubeValues = processSecretsAsFiles(
91
+ mergeWithMergingArrays(defaultKubeValues, {
92
+ jobs: removeFalsy(jobs),
93
+ cronjobs: removeFalsy(cronjobs),
92
94
 
93
- ...rest,
94
- });
95
+ ...rest,
96
+ }),
97
+ );
95
98
 
96
99
  return kubeValues;
97
100
  };
@@ -0,0 +1,35 @@
1
+ import { omit } from "lodash";
2
+ import type { DeployConfigKubernetesValues } from "../types";
3
+ import type { StringOrBashExpression } from "../../bash/BashExpression";
4
+
5
+ export const processSecretsAsFiles = <
6
+ T extends {
7
+ env: {
8
+ secret: Record<string, StringOrBashExpression>;
9
+ };
10
+ } & DeployConfigKubernetesValues,
11
+ >(
12
+ values: T,
13
+ ): T => {
14
+ if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
15
+ return values;
16
+ }
17
+ // the initial idea was that we "shadow" secrets that we mount as files,
18
+ // but there is a weird kubernetes issue with that (https://github.com/kubernetes/kubernetes/issues/46861),
19
+ // so instead we rename the secrets and append _content, so that inside kuberentes, we can use the original name to contain the path and name+_content as the actual content
20
+ return {
21
+ ...values,
22
+ env: {
23
+ ...values.env,
24
+ secret: {
25
+ ...omit(values.env.secret, values.secretsAsFile),
26
+ ...Object.fromEntries(
27
+ values.secretsAsFile.map((key) => [
28
+ key + "_content",
29
+ values.env.secret[key],
30
+ ]),
31
+ ),
32
+ },
33
+ },
34
+ };
35
+ };
@@ -25,6 +25,12 @@ export type DeployConfigBase = {
25
25
  */
26
26
  jobVars?: EnvVars;
27
27
 
28
+ /**
29
+ * additional env vars for the deploy job
30
+ *
31
+ * @deprecated use deploy.jobVars for deploy job specific variables
32
+ */
33
+ extraVars?: Record<string, string>;
28
34
  /**
29
35
  * additional vars only for the runner.
30
36
  * Also if you use services: that require env vars, you need to set them here.
@@ -164,6 +164,33 @@ export type DeployConfigMongodbReplicaset = {
164
164
  export type DeployConfigMongodb = DeployConfigMongodbBase &
165
165
  (DeployConfigMongodbStandalone | DeployConfigMongodbReplicaset);
166
166
 
167
+ /**
168
+ * @deprecated use config with instanceConnectionName
169
+ */
170
+ type DeployConfigKubernetesValuesCloudSQLLegacy = {
171
+ enabled: boolean;
172
+ /**
173
+ * @deprecated use config with instanceConnectionName
174
+ */
175
+ instanceId?: string;
176
+ /**
177
+ * @deprecated use config with instanceConnectionName
178
+ */
179
+ projectId?: string;
180
+ /**
181
+ * @deprecated use config with instanceConnectionName
182
+ */
183
+ region?: string;
184
+ /**
185
+ * @deprecated use type "unmanaged".
186
+ *
187
+ * Be aware that "unmanaged" is not fully backward compatible with "legacy".
188
+ *
189
+ *
190
+ */
191
+ type?: "legacy";
192
+ };
193
+
167
194
  export type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
168
195
  enabled: boolean;
169
196
  instanceConnectionName: string;
@@ -193,7 +220,8 @@ export type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
193
220
  dbBaseName?: string;
194
221
  };
195
222
  export type DeployConfigKubernetesValuesCloudSQL =
196
- DeployConfigKubernetesValuesCloudSQLUnmanaged;
223
+ | DeployConfigKubernetesValuesCloudSQLLegacy
224
+ | DeployConfigKubernetesValuesCloudSQLUnmanaged;
197
225
  export type DeployConfigKubernetesValues = AllowUnknownProps<{
198
226
  /**
199
227
  * enable cloudsql db. Currently you have to manually set it up
@@ -330,6 +358,13 @@ export type DeployConfigKubernetesValues = AllowUnknownProps<{
330
358
  mapServiceUrlToEnv?: {
331
359
  [envVar: string]: string;
332
360
  };
361
+ /**
362
+ * Mount secrets as files in the filesystem.
363
+ * These secrets are still available as env vars, but will contain the path of the file instead
364
+ *
365
+ * @deprecated this will be removed in the future, because its very niche and not used
366
+ */
367
+ secretsAsFile?: string[];
333
368
  }>;
334
369
 
335
370
  export type DeployConfigKubernetes = {
@@ -106,6 +106,7 @@ export const makeGitlabJob = (
106
106
  environment,
107
107
  envMode,
108
108
  needsStages,
109
+ needsOtherComponent,
109
110
  name,
110
111
  needs,
111
112
  jobTags,
@@ -309,7 +310,7 @@ function deduplicateNeeds(needs: GitlabJobDef["needs"]): GitlabJobDef["needs"] {
309
310
 
310
311
  function getGitlabNeedsForComponentJob(
311
312
  context: ComponentContext,
312
- { needsStages, needs }: CatladderJob<string>,
313
+ { needsStages, needs, needsOtherComponent }: CatladderJob<string>,
313
314
  allJobs: AllCatladderJobs,
314
315
  ): GitlabJobDef["needs"] {
315
316
  const needsFromStages = needsStages?.flatMap<CatladderJobNeed>((n) => {
@@ -352,6 +353,8 @@ function getGitlabNeedsForComponentJob(
352
353
  const cleanedNeeds: CatladderJob["needs"] = [
353
354
  ...(needsFromStages ?? []),
354
355
  ...(needs ?? []),
356
+ // pull in legacy needs from other component, which is now identical to needs
357
+ ...(needsOtherComponent ?? []),
355
358
  ];
356
359
 
357
360
  return cleanedNeeds
@@ -73,6 +73,14 @@ export type EnvVars = {
73
73
  * secret env vars. These vars can be managed with catladder/cli
74
74
  */
75
75
  secret?: string[];
76
+ /**
77
+ * @deprecated, use ${componentName:variableName} instead
78
+ *
79
+ * With fromComponents you can inject env vars from other components.
80
+ */
81
+ fromComponents?: {
82
+ [otherApp: string]: Record<string, string>;
83
+ };
76
84
  };
77
85
 
78
86
  export type DefaultEnvConfig = {
@@ -46,7 +46,10 @@ export type Environment = {
46
46
  * the full name of the app. We use this as RELEASE_NAME in kubernetes and the service name in google cloud run
47
47
  */
48
48
  fullName: StringOrBashExpression;
49
-
49
+ /**
50
+ * @deprecated this is the same as context.env, use that instead
51
+ */
52
+ shortName: string;
50
53
  /**
51
54
  * the environment slug without component name.
52
55
  */
@@ -155,6 +158,10 @@ export type ComponentContext<
155
158
  * the name of the component
156
159
  */
157
160
  name: string;
161
+ /**
162
+ * @deprecated use name instead
163
+ */
164
+ componentName: string;
158
165
 
159
166
  /**
160
167
  * the merged component config.
package/src/types/jobs.ts CHANGED
@@ -70,6 +70,14 @@ export type CatladderJob<S = BaseStage> = {
70
70
  */
71
71
  needs?: Array<CatladderJobNeed>;
72
72
 
73
+ /**
74
+ * @deprecated set `componentName` to `needs` if you want to wait for a job from another component
75
+ */
76
+ needsOtherComponent?: Array<{
77
+ componentName: string;
78
+ job: string;
79
+ artifacts: boolean;
80
+ }>;
73
81
  /**
74
82
  * cache config, we use here the same shape as gitlab itself
75
83
  */