@catladder/pipeline 1.170.0 → 2.0.0

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 (194) hide show
  1. package/dist/bash/BashExpression.d.ts +2 -6
  2. package/dist/bash/BashExpression.js +5 -15
  3. package/dist/bash/bashEscape.d.ts +34 -0
  4. package/dist/bash/bashEscape.js +114 -0
  5. package/dist/bash/bashYaml.js +25 -2
  6. package/dist/bash/getInjectVarsScript.js +4 -2
  7. package/dist/bash/index.d.ts +2 -0
  8. package/dist/bash/index.js +26 -0
  9. package/dist/build/base/createAppBuildJob.js +3 -3
  10. package/dist/build/base/writeDotEnv.js +6 -4
  11. package/dist/build/custom/testJob.js +12 -12
  12. package/dist/build/docker.d.ts +3 -3
  13. package/dist/build/node/buildJob.js +1 -1
  14. package/dist/build/node/cache.d.ts +2 -4
  15. package/dist/build/node/cache.js +3 -24
  16. package/dist/build/node/testJob.js +11 -11
  17. package/dist/build/rails/build.js +1 -1
  18. package/dist/build/rails/test.js +8 -8
  19. package/dist/build/types.d.ts +0 -10
  20. package/dist/constants.js +1 -1
  21. package/dist/context/createComponentContext.js +0 -1
  22. package/dist/context/getEnvConfig.js +2 -1
  23. package/dist/context/getEnvironment.js +1 -2
  24. package/dist/context/getEnvironmentVariables.d.ts +5 -6
  25. package/dist/context/getEnvironmentVariables.js +50 -38
  26. package/dist/deploy/base/deploy.js +3 -3
  27. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +2 -2
  28. package/dist/deploy/cloudRun/index.js +2 -2
  29. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
  30. package/dist/deploy/kubernetes/cloudSql/index.d.ts +2 -2
  31. package/dist/deploy/kubernetes/cloudSql/index.js +3 -14
  32. package/dist/deploy/kubernetes/deployJob.js +1 -3
  33. package/dist/deploy/kubernetes/index.js +2 -2
  34. package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -3
  35. package/dist/deploy/kubernetes/kubeValues.d.ts +3 -4
  36. package/dist/deploy/kubernetes/kubeValues.js +2 -3
  37. package/dist/deploy/types/base.d.ts +0 -6
  38. package/dist/deploy/types/kubernetes.d.ts +1 -34
  39. package/dist/globalScriptFunctions/index.d.ts +14 -0
  40. package/dist/globalScriptFunctions/index.js +37 -0
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.js +3 -1
  43. package/dist/pipeline/gitlab/createGitlabJobs.js +3 -5
  44. package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +1 -0
  45. package/dist/pipeline/gitlab/createGitlabPipeline.js +38 -2
  46. package/dist/pipeline/packageManager.js +1 -1
  47. package/dist/runner/index.d.ts +1 -1
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/types/config.d.ts +6 -9
  50. package/dist/types/context.d.ts +2 -9
  51. package/dist/types/gitlab-types.d.ts +1 -0
  52. package/dist/types/jobs.d.ts +0 -8
  53. package/dist/utils/gitlab.js +4 -1
  54. package/dist/utils/writeFiles.js +1 -7
  55. package/dist/variables/VariableValue.d.ts +3 -0
  56. package/dist/variables/VariableValue.js +5 -0
  57. package/dist/variables/VariableValueContainingReferences.d.ts +24 -0
  58. package/dist/variables/VariableValueContainingReferences.js +97 -0
  59. package/dist/variables/__tests__/resolveAllReferences.test.js +219 -0
  60. package/dist/variables/__tests__/resolveAllReferencesOnce.test.d.ts +1 -0
  61. package/dist/variables/__tests__/resolveAllReferencesOnce.test.js +171 -0
  62. package/dist/variables/__tests__/resolveReferencesOnce.test.d.ts +1 -0
  63. package/dist/variables/__tests__/resolveReferencesOnce.test.js +202 -0
  64. package/dist/variables/__tests__/variableValue.test.d.ts +1 -0
  65. package/dist/variables/__tests__/variableValue.test.js +36 -0
  66. package/dist/variables/resolveAllReferences.d.ts +3 -0
  67. package/dist/{bash/replaceAsync.js → variables/resolveAllReferences.js} +60 -41
  68. package/dist/variables/resolveAllReferencesOnce.d.ts +5 -0
  69. package/dist/variables/resolveAllReferencesOnce.js +191 -0
  70. package/dist/variables/resolveReferencesOnce.d.ts +8 -0
  71. package/dist/variables/resolveReferencesOnce.js +22 -0
  72. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +312 -238
  73. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +312 -238
  74. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +312 -222
  75. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +1436 -0
  76. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +312 -238
  77. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +316 -238
  78. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +312 -238
  79. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +313 -238
  80. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +312 -238
  81. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +312 -238
  82. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +312 -238
  83. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +312 -238
  84. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +316 -238
  85. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +294 -220
  86. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +312 -238
  87. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +652 -486
  88. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +282 -288
  89. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +312 -238
  90. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +284 -194
  91. package/examples/__snapshots__/custom-build-job.test.ts.snap +278 -188
  92. package/examples/__snapshots__/custom-deploy.test.ts.snap +220 -154
  93. package/examples/__snapshots__/custom-envs.test.ts.snap +216 -126
  94. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +278 -188
  95. package/examples/__snapshots__/git-submodule.test.ts.snap +312 -238
  96. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +231 -253
  97. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +240 -262
  98. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +504 -506
  99. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +239 -261
  100. package/examples/__snapshots__/local-dot-env.test.ts.snap +236 -238
  101. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +236 -242
  102. package/examples/__snapshots__/multiline-var.test.ts.snap +1355 -973
  103. package/examples/__snapshots__/native-app.test.ts.snap +438 -392
  104. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +312 -238
  105. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +312 -238
  106. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +186 -188
  107. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +162 -164
  108. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +4741 -0
  109. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +330 -228
  110. package/examples/__snapshots__/{workspace-api-www-custom-cache.test.ts.snap → workspace-api-www-turbo-cache.test.ts.snap} +457 -499
  111. package/examples/__snapshots__/workspace-api-www.test.ts.snap +452 -482
  112. package/examples/{workspace-api-www-custom-cache.test.ts → cloud-run-nextjs.test.ts} +2 -2
  113. package/examples/cloud-run-nextjs.ts +28 -0
  114. package/examples/cloud-run-with-sql.ts +0 -1
  115. package/examples/kubernetes-application-customization.ts +1 -0
  116. package/examples/kubernetes-with-cloud-sql.ts +1 -0
  117. package/examples/kubernetes-with-jobs.ts +1 -0
  118. package/examples/kubernetes-with-mongodb.ts +1 -0
  119. package/examples/meteor-kubernetes.ts +1 -1
  120. package/examples/native-app.ts +10 -7
  121. package/examples/rails-k8s-with-worker.ts +7 -1
  122. package/examples/{kubernetes-with-cloud-sql-legacy.test.ts → referencing-other-vars.test.ts} +2 -2
  123. package/examples/referencing-other-vars.ts +83 -0
  124. package/examples/workspace-api-www-turbo-cache.test.ts +11 -0
  125. package/examples/{workspace-api-www-custom-cache.ts → workspace-api-www-turbo-cache.ts} +4 -3
  126. package/examples/workspace-api-www.ts +3 -2
  127. package/package.json +2 -6
  128. package/src/bash/BashExpression.ts +10 -13
  129. package/src/bash/bashEscape.ts +158 -0
  130. package/src/bash/bashYaml.ts +36 -2
  131. package/src/bash/getInjectVarsScript.ts +11 -2
  132. package/src/bash/index.ts +2 -0
  133. package/src/build/base/createAppBuildJob.ts +0 -1
  134. package/src/build/base/writeDotEnv.ts +6 -6
  135. package/src/build/custom/testJob.ts +0 -1
  136. package/src/build/node/buildJob.ts +2 -2
  137. package/src/build/node/cache.ts +0 -29
  138. package/src/build/node/testJob.ts +0 -1
  139. package/src/build/rails/build.ts +0 -1
  140. package/src/build/rails/test.ts +0 -1
  141. package/src/build/types.ts +0 -13
  142. package/src/context/createComponentContext.ts +0 -1
  143. package/src/context/getEnvConfig.ts +2 -2
  144. package/src/context/getEnvironment.ts +1 -1
  145. package/src/context/getEnvironmentContext.ts +1 -1
  146. package/src/context/getEnvironmentVariables.ts +44 -51
  147. package/src/deploy/base/deploy.ts +1 -1
  148. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +4 -12
  149. package/src/deploy/cloudRun/index.ts +2 -2
  150. package/src/deploy/kubernetes/cloudSql/index.ts +3 -16
  151. package/src/deploy/kubernetes/deployJob.ts +0 -2
  152. package/src/deploy/kubernetes/index.ts +2 -2
  153. package/src/deploy/kubernetes/kubeEnv.ts +3 -3
  154. package/src/deploy/kubernetes/kubeValues.ts +5 -8
  155. package/src/deploy/types/base.ts +0 -6
  156. package/src/deploy/types/kubernetes.ts +1 -36
  157. package/src/globalScriptFunctions/index.ts +30 -0
  158. package/src/index.ts +2 -0
  159. package/src/pipeline/gitlab/createGitlabJobs.ts +1 -4
  160. package/src/pipeline/gitlab/createGitlabPipeline.ts +8 -1
  161. package/src/pipeline/packageManager.ts +7 -5
  162. package/src/runner/index.ts +0 -1
  163. package/src/types/config.ts +6 -9
  164. package/src/types/context.ts +3 -9
  165. package/src/types/gitlab-types.ts +1 -0
  166. package/src/types/jobs.ts +0 -8
  167. package/src/utils/gitlab.ts +19 -2
  168. package/src/utils/writeFiles.ts +1 -2
  169. package/src/variables/VariableValue.ts +6 -0
  170. package/src/variables/VariableValueContainingReferences.ts +89 -0
  171. package/src/variables/__tests__/resolveAllReferences.test.ts +110 -0
  172. package/src/variables/__tests__/resolveAllReferencesOnce.test.ts +64 -0
  173. package/src/variables/__tests__/resolveReferencesOnce.test.ts +117 -0
  174. package/src/variables/__tests__/variableValue.test.ts +73 -0
  175. package/src/variables/resolveAllReferences.ts +46 -0
  176. package/src/variables/resolveAllReferencesOnce.ts +44 -0
  177. package/src/variables/resolveReferencesOnce.ts +29 -0
  178. package/bin/catladder-gitlab-dev.js +0 -3
  179. package/bin/catladder-gitlab.js +0 -3
  180. package/dist/bash/replaceAsync.d.ts +0 -2
  181. package/dist/bundles/catladder-gitlab/index.js +0 -15
  182. package/dist/context/__tests__/resolveReferences.test.js +0 -368
  183. package/dist/context/resolveReferences.d.ts +0 -6
  184. package/dist/context/resolveReferences.js +0 -286
  185. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +0 -85
  186. package/dist/deploy/kubernetes/processSecretsAsFiles.js +0 -33
  187. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +0 -1795
  188. package/examples/kubernetes-with-cloud-sql-legacy.ts +0 -35
  189. package/scripts/bundle +0 -2
  190. package/src/bash/replaceAsync.ts +0 -54
  191. package/src/context/__tests__/resolveReferences.test.ts +0 -148
  192. package/src/context/resolveReferences.ts +0 -93
  193. package/src/deploy/kubernetes/processSecretsAsFiles.ts +0 -35
  194. /package/dist/{context/__tests__/resolveReferences.test.d.ts → variables/__tests__/resolveAllReferences.test.d.ts} +0 -0
@@ -1,35 +0,0 @@
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
- };
package/scripts/bundle DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- ncc build dist/catladder-gitlab.js -o dist/bundles/catladder-gitlab -e 'tsx/cjs/api' $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
@@ -1,54 +0,0 @@
1
- import { BashExpression, bashEscape } from "./BashExpression";
2
-
3
- // from https://github.com/dsblv/string-replace-async/blob/main/index.js
4
- // and adjusted a bit
5
- export default async function replaceAsync(
6
- string: string | BashExpression,
7
- searchValue: any,
8
- replacer: (
9
- substring: string,
10
- ...args: any[]
11
- ) => Promise<string | BashExpression>,
12
- ) {
13
- const wasBashExpression = string instanceof BashExpression;
14
-
15
- const stringRepresentation = wasBashExpression
16
- ? string.toString()
17
- : bashEscape(string);
18
- try {
19
- // 1. Run fake pass of `replace`, collect values from `replacer` calls
20
- // 2. Resolve them with `Promise.all`
21
- // 3. Run `replace` with resolved values
22
- const values: Array<Promise<string | BashExpression>> = [];
23
- String.prototype.replace.call(
24
- stringRepresentation,
25
- searchValue,
26
- function (...args) {
27
- // eslint-disable-next-line prefer-spread
28
- const result = replacer.apply(undefined, args);
29
- values.push(result);
30
- return "";
31
- },
32
- );
33
- const resolvedValues = await Promise.all(values);
34
-
35
- const containsBashExpression = resolvedValues.some(
36
- (value) => value instanceof BashExpression,
37
- );
38
-
39
- const result = String.prototype.replace.call(
40
- stringRepresentation,
41
- searchValue,
42
- function () {
43
- return resolvedValues.shift()?.toString() ?? "";
44
- },
45
- );
46
- if (wasBashExpression || containsBashExpression) {
47
- return new BashExpression(result);
48
- } else {
49
- return result;
50
- }
51
- } catch (error) {
52
- return Promise.reject(error);
53
- }
54
- }
@@ -1,148 +0,0 @@
1
- import type { BashExpression } from "../../bash/BashExpression";
2
- import {
3
- resolveReferences,
4
- translateLegacyFromComponents,
5
- } from "../resolveReferences";
6
-
7
- const unpackBashExpressions = (obj: Record<string, string | BashExpression>) =>
8
- Object.fromEntries(
9
- Object.entries(obj).map(([key, value]) => [key, value.toString()]),
10
- );
11
- describe("resolveReferences", () => {
12
- it("replaces occurences of ${componentName:VARIABLE_NAME}", async () => {
13
- const variables = {
14
- a: "hello world",
15
- b: "a replaced value looks like this: '${api:FOO}', nice!",
16
- };
17
- const otherVariables: Record<string, Record<string, string>> = {
18
- api: {
19
- FOO: "foo from api",
20
- },
21
- frontend: {
22
- FOO: "foo from frontend",
23
- },
24
- };
25
- const result = await resolveReferences(variables, async (componentName) => {
26
- return otherVariables[componentName];
27
- });
28
-
29
- expect(unpackBashExpressions(result)).toEqual({
30
- a: "hello world",
31
- b: "a replaced value looks like this: 'foo from api', nice!",
32
- });
33
- });
34
-
35
- it("replaces self references with structure ${VARIABLE_NAME}", async () => {
36
- const variables = {
37
- FOO: "hello world",
38
- BAR: "this: ${FOO}!",
39
- };
40
- const result = await resolveReferences(variables);
41
-
42
- expect(unpackBashExpressions(result)).toEqual({
43
- FOO: "hello world",
44
- BAR: "this: hello world!",
45
- });
46
- });
47
-
48
- it("replaces self references mixed with other vars", async () => {
49
- const variables = {
50
- FOO: "hello from ${api:FOO}",
51
- BAR: "this: ${FOO}!",
52
- };
53
- const otherVariables: Record<string, Record<string, string>> = {
54
- api: {
55
- FOO: "foo from api",
56
- },
57
- };
58
- const result = await resolveReferences(variables, async (componentName) => {
59
- return otherVariables[componentName];
60
- });
61
-
62
- expect(unpackBashExpressions(result)).toEqual({
63
- FOO: "hello from foo from api",
64
- BAR: "this: hello from foo from api!",
65
- });
66
- });
67
-
68
- it("keeps variables as is if not found (when null is returned)", async () => {
69
- const variables = {
70
- a: "hello world",
71
- b: "a not found value looks like this: '${api:FOO}'",
72
- };
73
- const otherVariables: Record<string, Record<string, string>> = {};
74
- const result = await resolveReferences(variables, async (componentName) => {
75
- return otherVariables[componentName];
76
- });
77
-
78
- expect(unpackBashExpressions(result)).toEqual({
79
- a: "hello world",
80
- b: "a not found value looks like this: '${api:FOO}'",
81
- });
82
- });
83
-
84
- it("replaces mulitple levels deep", async () => {
85
- const variables = {
86
- a: "value is ${frontend:FOO}!",
87
- };
88
- const otherVariables: Record<string, Record<string, string>> = {
89
- api: {
90
- FOO: "foo from api",
91
- },
92
- frontend: {
93
- FOO: "hi, ${api:FOO}",
94
- },
95
- };
96
- const result = await resolveReferences(variables, async (componentName) => {
97
- return otherVariables[componentName];
98
- });
99
-
100
- expect(unpackBashExpressions(result)).toEqual({
101
- a: "value is hi, foo from api!",
102
- });
103
- });
104
-
105
- it("prevents endless loops", async () => {
106
- const variables = {
107
- a: "value is ${frontend:FOO}!",
108
- };
109
- const otherVariables: Record<string, Record<string, string>> = {
110
- api: {
111
- FOO: "api ${frontend:FOO}",
112
- },
113
- frontend: {
114
- FOO: "frontend ${api:FOO}",
115
- },
116
- };
117
- const result = await resolveReferences(variables, async (componentName) => {
118
- return otherVariables[componentName];
119
- });
120
-
121
- expect(unpackBashExpressions(result)).toEqual({
122
- a: "value is frontend api ${frontend:FOO}!",
123
- });
124
- });
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
- });
@@ -1,93 +0,0 @@
1
- import { merge } from "lodash";
2
-
3
- import type { BashExpression } from "../bash/BashExpression";
4
- import replaceAsync from "../bash/replaceAsync";
5
- import type { UnspecifiedEnvVars } from "..";
6
-
7
- // regex to resolve references in catladder variables
8
- // those expressions have the pattern ${componentName:variableName}
9
- const REGEX = /\$\{(([^:}]+):)?([^}]+)}/gm;
10
-
11
- export const resolveReferences = async (
12
- vars: Record<string, string | BashExpression | undefined | null>,
13
- getOtherVariables?: (
14
- componentName: string,
15
- alreadyVisited: Record<string, Record<string, boolean>>,
16
- ) => Promise<UnspecifiedEnvVars>,
17
- alreadyVisitedBase: Record<string, Record<string, boolean>> = {},
18
- ) => {
19
- /**
20
- *
21
- * replace referenced variables with their values in a value string
22
- */
23
- const replaceSingleValue = async (
24
- value: string | BashExpression,
25
- alreadyVisited: Record<
26
- string,
27
- Record<string, boolean>
28
- > = alreadyVisitedBase,
29
- ): Promise<string | BashExpression> => {
30
- if (REGEX.test(value.toString())) {
31
- // we consider variables that got references in it BashExpressions, because the replacement may be one
32
-
33
- return await replaceAsync(
34
- value,
35
- REGEX,
36
- async (match, _, componentName, variableName) => {
37
- if (alreadyVisited[componentName]?.[variableName]) {
38
- return match; // prevent endless loop
39
- }
40
- const newAlreadyVisited = merge({}, alreadyVisited, {
41
- [componentName]: {
42
- [variableName]: true,
43
- },
44
- });
45
- const result = componentName
46
- ? (await getOtherVariables?.(componentName, newAlreadyVisited).then(
47
- (r) => r?.[variableName],
48
- )) ?? null
49
- : vars[variableName]; // is self reference
50
-
51
- const replaced =
52
- result !== null && result !== undefined
53
- ? await replaceSingleValue(result, newAlreadyVisited)
54
- : match;
55
-
56
- return replaced;
57
- },
58
- );
59
- } else {
60
- return value;
61
- }
62
- };
63
-
64
- return Object.fromEntries(
65
- await Promise.all(
66
- Object.entries(vars).map(async ([key, value]) => {
67
- if (value === null || value === undefined) {
68
- return [key, null];
69
- }
70
-
71
- return [
72
- key,
73
- value !== null && value !== undefined
74
- ? await replaceSingleValue(value)
75
- : null,
76
- ];
77
- }),
78
- ),
79
- ) as Record<string, BashExpression>;
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
- };
@@ -1,35 +0,0 @@
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
- };