@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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catladder/pipeline",
3
- "version": "1.77.1",
3
+ "version": "1.78.0",
4
4
  "scripts": {
5
5
  "build:tsc": "yarn tsc",
6
6
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -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, rest)
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
- AllowUnknownProps<{
164
- /**
165
- * the command to execute
166
- */
167
- command: string;
168
- /**
169
- * comma-separated list of helm hooks, see https://helm.sh/docs/topics/charts_hooks/
170
- *
171
- * defaults to post-install,post-upgrade
172
- */
173
- hook?: string;
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
- AllowUnknownProps<{
182
- schedule: string;
183
- command: string;
184
- concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
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)