@catladder/pipeline 1.77.1 → 1.78.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.
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/deploy/kubernetes/kubeValues.d.ts +13 -10
- package/dist/deploy/kubernetes/kubeValues.js +47 -2
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -2
- package/dist/deploy/types/kubernetes.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
- package/examples/kubernetes-with-jobs.ts +68 -0
- package/package.json +1 -1
- package/src/deploy/kubernetes/kubeValues.ts +14 -2
- package/src/deploy/types/kubernetes.ts +19 -17
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
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
|
+
jobs: {
|
|
23
|
+
migration: {
|
|
24
|
+
command: "yarn migrate",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
cronjobs: {
|
|
28
|
+
["send-emails"]: {
|
|
29
|
+
command: "yarn send emails",
|
|
30
|
+
schedule: "0 * * * *",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
env: {
|
|
36
|
+
review: {
|
|
37
|
+
deploy: {
|
|
38
|
+
values: {
|
|
39
|
+
cronjobs: {
|
|
40
|
+
["send-emails"]: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
www: {
|
|
48
|
+
dir: "www",
|
|
49
|
+
build: {
|
|
50
|
+
type: "node",
|
|
51
|
+
},
|
|
52
|
+
deploy: {
|
|
53
|
+
type: "kubernetes",
|
|
54
|
+
cluster: {
|
|
55
|
+
name: "some-cluster-name",
|
|
56
|
+
region: "europe-west6",
|
|
57
|
+
projectId: "some-project-id",
|
|
58
|
+
type: "gcloud",
|
|
59
|
+
domainCanonical: "panter.cloud",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
it("matches snapshot", async () => {
|
|
67
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
68
|
+
});
|
package/package.json
CHANGED
|
@@ -44,6 +44,13 @@ const createAppConfig = (
|
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
const removeFalsy = <T>(record?: Record<string, false | T>) => {
|
|
48
|
+
if (!record) return undefined;
|
|
49
|
+
return Object.fromEntries(
|
|
50
|
+
Object.entries(record).filter(([, value]) => value !== false)
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
47
54
|
export const createKubeValues = (context: Context) => {
|
|
48
55
|
const deployConfig = context.componentConfig.deploy;
|
|
49
56
|
if (deployConfig === false) {
|
|
@@ -59,7 +66,7 @@ export const createKubeValues = (context: Context) => {
|
|
|
59
66
|
// we remove the application config because it can be just the value `false` which is a convenience feature, but not supported in the helm chart
|
|
60
67
|
// we only merge the rest of the values in
|
|
61
68
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
-
const { application, ...rest } = values ?? {};
|
|
69
|
+
const { application, jobs, cronjobs, ...rest } = values ?? {};
|
|
63
70
|
|
|
64
71
|
const env = createKubeEnv(context);
|
|
65
72
|
|
|
@@ -75,7 +82,12 @@ export const createKubeValues = (context: Context) => {
|
|
|
75
82
|
);
|
|
76
83
|
|
|
77
84
|
const kubeValues = processSecretsAsFiles(
|
|
78
|
-
mergeWithMergingArrays(defaultKubeValues,
|
|
85
|
+
mergeWithMergingArrays(defaultKubeValues, {
|
|
86
|
+
jobs: removeFalsy(jobs),
|
|
87
|
+
cronjobs: removeFalsy(cronjobs),
|
|
88
|
+
|
|
89
|
+
...rest,
|
|
90
|
+
})
|
|
79
91
|
);
|
|
80
92
|
|
|
81
93
|
return kubeValues;
|
|
@@ -160,29 +160,31 @@ export type DeployConfigKubernetesValues = AllowUnknownProps<{
|
|
|
160
160
|
*/
|
|
161
161
|
jobs?: Record<
|
|
162
162
|
string,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
| false
|
|
164
|
+
| AllowUnknownProps<{
|
|
165
|
+
/**
|
|
166
|
+
* the command to execute
|
|
167
|
+
*/
|
|
168
|
+
command: string;
|
|
169
|
+
/**
|
|
170
|
+
* comma-separated list of helm hooks, see https://helm.sh/docs/topics/charts_hooks/
|
|
171
|
+
*
|
|
172
|
+
* defaults to post-install,post-upgrade
|
|
173
|
+
*/
|
|
174
|
+
hook?: string;
|
|
175
|
+
}>
|
|
175
176
|
>;
|
|
176
177
|
/**
|
|
177
178
|
* cronjobs that run periodically. These use the app image have all env vars available.
|
|
178
179
|
*/
|
|
179
180
|
cronjobs?: Record<
|
|
180
181
|
string,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
| false
|
|
183
|
+
| AllowUnknownProps<{
|
|
184
|
+
schedule: string;
|
|
185
|
+
command: string;
|
|
186
|
+
concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
|
|
187
|
+
}>
|
|
186
188
|
>;
|
|
187
189
|
/**
|
|
188
190
|
* configuration for the application ("Deployment" in kubernetes)
|