@catladder/pipeline 0.0.0-refactor-docker-c24f8608 → 0.0.0-refactor-docker-45f6e733

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 (78) hide show
  1. package/dist/build/base/createAppBuildJob.js +6 -6
  2. package/dist/build/base/writeBuildInfo.js +1 -1
  3. package/dist/build/base/writeDotEnv.js +1 -1
  4. package/dist/build/custom/__tests__/testJob.test.js +11 -14
  5. package/dist/build/custom/buildJob.js +3 -3
  6. package/dist/build/custom/testJob.js +5 -5
  7. package/dist/build/docker.d.ts +2 -6
  8. package/dist/build/docker.js +13 -10
  9. package/dist/build/node/buildJob.js +7 -7
  10. package/dist/build/node/cache.js +1 -1
  11. package/dist/build/node/meteor.js +5 -5
  12. package/dist/build/node/testJob.js +11 -11
  13. package/dist/build/rails/build.js +3 -3
  14. package/dist/build/rails/test.js +4 -4
  15. package/dist/build/sbom.js +2 -2
  16. package/dist/bundles/catladder-gitlab/index.js +181 -162
  17. package/dist/constants.js +1 -1
  18. package/dist/context/getLabels.js +1 -1
  19. package/dist/context/index.js +34 -12
  20. package/dist/deploy/base/deploy.js +9 -8
  21. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +1 -5
  22. package/dist/deploy/cloudRun/artifactsRegistry.js +8 -9
  23. package/dist/deploy/cloudRun/cloudRunRevisions.js +4 -5
  24. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +1 -1
  25. package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
  26. package/dist/deploy/cloudRun/createJobs/common.js +2 -1
  27. package/dist/deploy/cloudRun/createJobs/index.js +2 -4
  28. package/dist/deploy/custom/deployJob.js +7 -10
  29. package/dist/deploy/dockerTag/deployJob.js +3 -5
  30. package/dist/deploy/kubernetes/cloudSql/index.js +11 -9
  31. package/dist/deploy/kubernetes/deployJob.js +4 -7
  32. package/dist/deploy/kubernetes/kubeEnv.js +2 -1
  33. package/dist/deploy/kubernetes/kubeValues.js +10 -10
  34. package/dist/deploy/kubernetes/mongodb.js +11 -11
  35. package/dist/deploy/sbom.js +1 -1
  36. package/dist/deploy/types/index.d.ts +1 -1
  37. package/dist/deploy/types/index.js +1 -1
  38. package/dist/deploy/utils.js +2 -1
  39. package/dist/pipeline/createJobsForComponent.js +5 -5
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/dist/types/config.d.ts +1 -1
  42. package/dist/types/context.d.ts +13 -1
  43. package/package.json +1 -1
  44. package/src/build/base/createAppBuildJob.ts +7 -7
  45. package/src/build/base/writeBuildInfo.ts +1 -1
  46. package/src/build/base/writeDotEnv.ts +1 -1
  47. package/src/build/custom/__tests__/testJob.test.ts +5 -8
  48. package/src/build/custom/buildJob.ts +4 -4
  49. package/src/build/custom/testJob.ts +5 -5
  50. package/src/build/docker.ts +21 -14
  51. package/src/build/node/buildJob.ts +8 -8
  52. package/src/build/node/cache.ts +1 -1
  53. package/src/build/node/meteor.ts +9 -15
  54. package/src/build/node/testJob.ts +14 -14
  55. package/src/build/rails/build.ts +3 -3
  56. package/src/build/rails/test.ts +4 -4
  57. package/src/build/sbom.ts +3 -3
  58. package/src/context/getLabels.ts +1 -1
  59. package/src/context/index.ts +21 -5
  60. package/src/deploy/base/deploy.ts +8 -14
  61. package/src/deploy/cloudRun/artifactsRegistry.ts +5 -10
  62. package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -5
  63. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +1 -1
  64. package/src/deploy/cloudRun/createJobs/common.ts +5 -5
  65. package/src/deploy/cloudRun/createJobs/index.ts +1 -4
  66. package/src/deploy/custom/deployJob.ts +4 -6
  67. package/src/deploy/dockerTag/deployJob.ts +2 -5
  68. package/src/deploy/kubernetes/cloudSql/index.ts +7 -4
  69. package/src/deploy/kubernetes/deployJob.ts +1 -4
  70. package/src/deploy/kubernetes/kubeEnv.ts +1 -1
  71. package/src/deploy/kubernetes/kubeValues.ts +3 -3
  72. package/src/deploy/kubernetes/mongodb.ts +6 -6
  73. package/src/deploy/sbom.ts +1 -2
  74. package/src/deploy/types/index.ts +2 -2
  75. package/src/deploy/utils.ts +1 -1
  76. package/src/pipeline/createJobsForComponent.ts +6 -10
  77. package/src/types/config.ts +3 -1
  78. package/src/types/context.ts +16 -1
@@ -8,10 +8,7 @@ import { isOfDeployType } from "../types";
8
8
  export const createDockerTagDeployJobs = (
9
9
  context: ComponentContext,
10
10
  ): CatladderJob[] => {
11
- const deployConfig = context.componentConfig.deploy;
12
- if (deployConfig === false) {
13
- return [];
14
- }
11
+ const deployConfig = context.deploy?.config;
15
12
  if (!isOfDeployType(deployConfig, "dockerTag")) {
16
13
  // should not happen
17
14
  throw new Error("deploy config is not dockerTag");
@@ -19,7 +16,7 @@ export const createDockerTagDeployJobs = (
19
16
  const tag = deployConfig.tag;
20
17
  return createDeployementJobs(context, {
21
18
  deploy: {
22
- ...getDockerJobBaseProps(context),
19
+ ...getDockerJobBaseProps(),
23
20
  script: [
24
21
  ...gitlabDockerLogin(context),
25
22
  `docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG`,
@@ -5,8 +5,10 @@ import { getFullDbName } from "../../cloudSql/utils";
5
5
  import { isOfDeployType } from "../../types";
6
6
 
7
7
  export const hasKubernetesCloudSQL = (context: ComponentContext) => {
8
- if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
9
- return context.componentConfig.deploy.values?.cloudsql?.enabled;
8
+ const deployConfig = context.deploy?.config;
9
+
10
+ if (isOfDeployType(deployConfig, "kubernetes")) {
11
+ return deployConfig.values?.cloudsql?.enabled;
10
12
  }
11
13
  return false;
12
14
  };
@@ -24,11 +26,12 @@ export const createKubernetesCloudsqlBaseValues = (
24
26
  ): {
25
27
  cloudsql: CloudSqlValues;
26
28
  } => {
27
- if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
29
+ const deployConfig = context.deploy?.config;
30
+ if (!isOfDeployType(deployConfig, "kubernetes")) {
28
31
  throw new Error("cannot get cloud sql config");
29
32
  }
30
33
 
31
- const config = context.componentConfig.deploy.values?.cloudsql;
34
+ const config = deployConfig.values?.cloudsql;
32
35
 
33
36
  if (!config) {
34
37
  throw new Error("cannot get cloud sql config");
@@ -17,10 +17,7 @@ const ALL_VALUES_FILE = "__all_values.yml";
17
17
  export const createKubernetesDeployJobs = (
18
18
  context: ComponentContext,
19
19
  ): CatladderJob[] => {
20
- const deployConfig = context.componentConfig.deploy;
21
- if (deployConfig === false) {
22
- return [];
23
- }
20
+ const deployConfig = context.deploy?.config;
24
21
  if (!isOfDeployType(deployConfig, "kubernetes")) {
25
22
  // should not happen
26
23
  throw new Error("deploy config is not kubernetes");
@@ -15,7 +15,7 @@ const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
15
15
  * we evalulate the actual values later, but want to store the secrets in kubernetes secrets
16
16
  */
17
17
  export const createKubeEnv = (context: ComponentContext) => {
18
- if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
18
+ if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
19
19
  // should not happen
20
20
  throw new Error("deploy config is not kubernetes");
21
21
  }
@@ -28,7 +28,7 @@ const createAppConfig = (
28
28
  return mergeWithMergingArrays(
29
29
  {
30
30
  host: context.environment.host,
31
- command: command ?? context.componentConfig.build.startCommand,
31
+ command: command ?? context.build.config.startCommand,
32
32
  livenessProbe: {
33
33
  httpGet: {
34
34
  path: healthRoute ?? "__health",
@@ -57,8 +57,8 @@ const removeFalsy = <T>(record?: Record<string, false | T>) => {
57
57
  };
58
58
 
59
59
  export const createKubeValues = (context: ComponentContext) => {
60
- const deployConfig = context.componentConfig.deploy;
61
- if (deployConfig === false) {
60
+ const deployConfig = context.deploy?.config;
61
+ if (!deployConfig) {
62
62
  return [];
63
63
  }
64
64
  if (!isOfDeployType(deployConfig, "kubernetes")) {
@@ -23,10 +23,10 @@ const getMongodbReplicasetHost = (context: ComponentContext, index: number) => {
23
23
  );
24
24
  };
25
25
  const createMongodbUrl = (context: ComponentContext, dbName: string) => {
26
- if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
26
+ if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
27
27
  throw new Error("can only createMongodbUrl on supported deploys");
28
28
  }
29
- const mongodbConfig = context.componentConfig.deploy.values?.mongodb;
29
+ const mongodbConfig = context.deploy?.config.values?.mongodb;
30
30
 
31
31
  let queryParams: string | undefined = undefined;
32
32
 
@@ -47,10 +47,10 @@ const createMongodbUrl = (context: ComponentContext, dbName: string) => {
47
47
  }`;
48
48
  };
49
49
  const createMongoBackupDefaultConfig = (context: ComponentContext) => {
50
- if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
50
+ if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
51
51
  throw new Error("can only create mongodb base config on supported deploys");
52
52
  }
53
- const mongodbConfig = context.componentConfig.deploy.values?.mongodb;
53
+ const mongodbConfig = context.deploy?.config.values?.mongodb;
54
54
  const fullAppName = context.environment.envVars.KUBE_APP_NAME;
55
55
  const backupEnabled = ["prod", "stage"].includes(context.environment.envType);
56
56
 
@@ -84,10 +84,10 @@ const createMongoBackupDefaultConfig = (context: ComponentContext) => {
84
84
  };
85
85
  };
86
86
  export const createMongodbBaseConfig = (context: ComponentContext) => {
87
- if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
87
+ if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
88
88
  throw new Error("can only create mongodb base config on supported deploys");
89
89
  }
90
- const mongodbConfig = context.componentConfig.deploy.values?.mongodb;
90
+ const mongodbConfig = context.deploy?.config.values?.mongodb;
91
91
 
92
92
  return {
93
93
  mongodb: {
@@ -2,8 +2,7 @@ import type { ComponentContext } from "../types/context";
2
2
  import { SBOM_FILE } from "../build/sbom";
3
3
 
4
4
  export const sbomDeactivated = (context: ComponentContext) =>
5
- context.componentConfig.build.type === "custom" &&
6
- context.componentConfig.build.sbom === false;
5
+ context.build.config.type === "custom" && context.build.config.sbom === false;
7
6
 
8
7
  export const getDependencyTrackUploadScript = (
9
8
  context: ComponentContext,
@@ -21,8 +21,8 @@ export type DeployConfigGeneric<T extends DeployConfigType> = Extract<
21
21
  >;
22
22
 
23
23
  export const isOfDeployType = <T extends Array<DeployConfigType>>(
24
- t: DeployConfig | false,
24
+ t: DeployConfig | false | null | undefined,
25
25
  ...types: T
26
26
  ): t is Extract<DeployConfig, { type: T[number] }> => {
27
- return t && types.includes(t.type);
27
+ return t && types.includes(t.type) ? true : false;
28
28
  };
@@ -18,7 +18,7 @@ export const getKubernetesNamespace = (
18
18
  };
19
19
 
20
20
  export const contextIsStoppable = (context: ComponentContext) => {
21
- const deployConfig = context.componentConfig.deploy;
21
+ const deployConfig = context.deploy?.config;
22
22
  if (isOfDeployType(deployConfig, "kubernetes")) {
23
23
  return true;
24
24
  }
@@ -23,21 +23,17 @@ const injectDefaultVarsInCustomJobs = (
23
23
  ...job,
24
24
  }));
25
25
  const getCustomJobs = (context: ComponentContext) => {
26
- if (!context.componentConfig.customJobs) {
26
+ if (!context.customJobs) {
27
27
  return [];
28
28
  }
29
- const rawJobs = isFunction(context.componentConfig.customJobs)
30
- ? context.componentConfig.customJobs(context)
31
- : context.componentConfig.customJobs;
29
+ const rawJobs = context.customJobs;
32
30
  return injectDefaultVarsInCustomJobs(context, rawJobs);
33
31
  };
34
32
  const createRawJobs = (context: Context): CatladderJob[] => {
35
- const buildJobs =
36
- BUILD_TYPES[context.componentConfig.build.type].jobs(context);
37
- const deployJobs =
38
- context.componentConfig.deploy !== false
39
- ? DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context)
40
- : [];
33
+ const buildJobs = BUILD_TYPES[context.build.config.type].jobs(context);
34
+ const deployJobs = context.deploy?.config
35
+ ? DEPLOY_TYPES[context.deploy?.config.type].jobs(context)
36
+ : [];
41
37
 
42
38
  const customJobs = getCustomJobs(context);
43
39
  return [...buildJobs, ...deployJobs, ...customJobs];
@@ -151,7 +151,9 @@ export type ComponentConfig<C extends ConfigProps = never> = {
151
151
  * to let us know about why you need to use custom jobs.
152
152
  * This feedback will help us to generalize use cases
153
153
  */
154
- customJobs?: CatladderJob[] | ((context: ComponentContext) => CatladderJob[]);
154
+ customJobs?:
155
+ | CatladderJob[]
156
+ | ((context: Omit<ComponentContext, "customJobs">) => CatladderJob[]);
155
157
 
156
158
  /**
157
159
  * whether to create a .env
@@ -1,6 +1,7 @@
1
1
  import type { StringOrBashExpression } from "../bash/BashExpression";
2
2
  import type { BuildConfig } from "../build";
3
3
  import type { PredefinedVariables, SecretEnvVar } from "../context";
4
+ import type { DeployConfig } from "../deploy";
4
5
  import type {
5
6
  PipelineTrigger,
6
7
  ComponentConfig,
@@ -89,10 +90,22 @@ export type BuildContext = {
89
90
  packageManagerInfo?: PackageManagerInfo;
90
91
  config: BuildConfig;
91
92
  };
93
+
94
+ export type DeployContext = {
95
+ config: DeployConfig;
96
+ };
92
97
  export type ComponentContext = {
93
98
  componentName: string;
99
+
100
+ /**
101
+ * the merged component config.
102
+ *
103
+ * use build.config and deploy.config instead if you need something from there
104
+ *
105
+ */
94
106
  componentConfig: ComponentConfig;
95
- buildContext: BuildContext;
107
+ build: BuildContext;
108
+ deploy?: DeployContext | null;
96
109
  fullConfig: Config;
97
110
  environment: Environment;
98
111
 
@@ -102,6 +115,8 @@ export type ComponentContext = {
102
115
  * @deprecated use buildContext.packageManagerInfo instead
103
116
  */
104
117
  packageManagerInfo?: PackageManagerInfo;
118
+
119
+ customJobs?: CatladderJob[];
105
120
  };
106
121
 
107
122
  /**