@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-refactor-env-context-9e652b63
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/bin/catladder-gitlab.js +1 -1
- package/dist/build/base/createBuildJob.d.ts +2 -2
- package/dist/build/base/getBuildInfo.d.ts +1 -1
- package/dist/build/docker.d.ts +44 -6
- package/dist/build/docker.js +45 -19
- package/dist/build/index.d.ts +6 -5
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/index.d.ts +1 -1
- package/dist/build/node/meteor.d.ts +1 -1
- package/dist/build/node/meteor.js +6 -0
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +3 -0
- package/dist/build/node/yarn.d.ts +1 -1
- package/dist/build/node/yarn.js +13 -1
- package/dist/build/types.d.ts +10 -0
- package/dist/bundles/catladder-gitlab/index.js +32457 -0
- package/dist/catladder-gitlab.js +1 -2
- package/dist/config/configruedEnvs.d.ts +1 -1
- package/dist/config/readConfig.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context/getEnvConfig.d.ts +9 -0
- package/dist/context/getEnvConfig.js +26 -0
- package/dist/context/getEnvType.d.ts +4 -0
- package/dist/context/getEnvType.js +18 -0
- package/dist/context/getEnvironment.d.ts +3 -0
- package/dist/context/getEnvironment.js +187 -0
- package/dist/context/getEnvironmentContext.d.ts +4 -0
- package/dist/context/getEnvironmentContext.js +36 -0
- package/dist/context/getEnvironmentVariables.d.ts +10 -0
- package/dist/context/getEnvironmentVariables.js +322 -0
- package/dist/context/getLabels.d.ts +8 -0
- package/dist/context/getLabels.js +49 -0
- package/dist/context/index.d.ts +5 -6
- package/dist/context/index.js +176 -181
- package/dist/context/resolveReferences.d.ts +1 -3
- package/dist/context/resolveReferences.js +275 -26
- package/dist/context/resolveReferences.test.js +332 -81
- package/dist/defaults/index.d.ts +1 -1
- package/dist/deploy/base.d.ts +4 -2
- package/dist/deploy/base.js +37 -17
- package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
- package/dist/deploy/cloudRun/deployJob.js +139 -0
- package/dist/deploy/cloudRun/index.d.ts +9 -0
- package/dist/deploy/cloudRun/index.js +56 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +14 -0
- package/dist/deploy/cloudSql/index.d.ts +8 -0
- package/dist/deploy/cloudSql/index.js +30 -0
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +4 -1
- package/dist/deploy/custom/index.d.ts +2 -1
- package/dist/deploy/custom/index.js +15 -18
- package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
- package/dist/deploy/dockerTag/deployJob.js +33 -0
- package/dist/deploy/dockerTag/index.d.ts +2 -0
- package/dist/deploy/dockerTag/index.js +19 -0
- package/dist/deploy/index.d.ts +12 -8
- package/dist/deploy/index.js +27 -14
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
- package/dist/deploy/kubernetes/additionalSecretKeys.js +33 -0
- package/dist/deploy/kubernetes/cloudsql.d.ts +1 -1
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +13 -66
- package/dist/deploy/kubernetes/index.d.ts +2 -1
- package/dist/deploy/kubernetes/index.js +45 -16
- package/dist/deploy/kubernetes/kubeEnv.d.ts +10 -0
- package/dist/deploy/kubernetes/kubeEnv.js +90 -0
- package/dist/deploy/kubernetes/kubeValues.d.ts +90 -0
- package/dist/deploy/kubernetes/kubeValues.js +96 -0
- package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
- package/dist/deploy/kubernetes/mongodb.js +118 -8
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +21 -21
- package/dist/deploy/types/base.d.ts +15 -0
- package/dist/deploy/types/base.js +3 -0
- package/dist/deploy/types/custom.d.ts +27 -0
- package/dist/deploy/types/custom.js +3 -0
- package/dist/deploy/types/dockerTag.d.ts +10 -0
- package/dist/deploy/types/dockerTag.js +3 -0
- package/dist/deploy/types/googleCloudRun.d.ts +39 -0
- package/dist/deploy/types/googleCloudRun.js +3 -0
- package/dist/deploy/types/index.d.ts +24 -0
- package/dist/deploy/types/index.js +41 -0
- package/dist/deploy/{types.d.ts → types/kubernetes.d.ts} +128 -36
- package/dist/deploy/types/kubernetes.js +3 -0
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/deploy/utils.js +4 -0
- package/dist/pipeline/createChildPipeline.d.ts +2 -2
- package/dist/pipeline/createChildPipeline.js +3 -3
- package/dist/pipeline/createJobs.d.ts +2 -2
- package/dist/pipeline/createJobs.js +63 -25
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +3 -2
- package/dist/pipeline/gitlab/makeGitlabJob.js +2 -1
- package/dist/pipeline/packageManager.d.ts +1 -1
- package/dist/rules/index.d.ts +1 -1
- package/dist/runner/index.d.ts +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +7 -6
- package/dist/types/config.js +1 -1
- package/dist/types/context.d.ts +10 -2
- package/dist/types/environmentContext.d.ts +22 -0
- package/dist/types/environmentContext.js +3 -0
- package/dist/types/gitlab-types.d.ts +1 -1
- package/dist/types/jobs.d.ts +8 -3
- package/dist/types/jobs.js +1 -1
- package/dist/types/pipeline.d.ts +1 -1
- package/package.json +15 -11
- package/scripts/bundle +2 -0
- package/src/build/base/createBuildJob.ts +3 -2
- package/src/build/base/getBuildInfo.ts +1 -1
- package/src/build/docker.ts +47 -29
- package/src/build/index.ts +8 -5
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +2 -2
- package/src/build/node/index.ts +1 -1
- package/src/build/node/meteor.ts +8 -2
- package/src/build/node/testJob.ts +4 -2
- package/src/build/node/yarn.ts +21 -10
- package/src/build/tests/storybook.test.ts +1 -1
- package/src/build/types.ts +13 -1
- package/src/catladder-gitlab.ts +4 -2
- package/src/config/configruedEnvs.test.ts +2 -2
- package/src/config/configruedEnvs.ts +5 -4
- package/src/config/readConfig.ts +1 -1
- package/src/context/getEnvConfig.ts +21 -0
- package/src/context/getEnvType.ts +17 -0
- package/src/context/getEnvironment.ts +40 -0
- package/src/context/getEnvironmentContext.ts +57 -0
- package/src/context/getEnvironmentVariables.ts +152 -0
- package/src/context/getLabels.ts +20 -0
- package/src/context/index.ts +25 -191
- package/src/context/resolveReferences.test.ts +15 -15
- package/src/context/resolveReferences.ts +37 -30
- package/src/defaults/index.ts +1 -1
- package/src/deploy/base.ts +43 -19
- package/src/deploy/cloudRun/deployJob.ts +104 -0
- package/src/deploy/cloudRun/index.ts +48 -0
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
- package/src/deploy/cloudSql/index.ts +16 -0
- package/src/deploy/custom/deployJob.ts +10 -3
- package/src/deploy/custom/index.ts +9 -1
- package/src/deploy/dockerTag/deployJob.ts +31 -0
- package/src/deploy/dockerTag/index.ts +9 -0
- package/src/deploy/index.ts +26 -17
- package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
- package/src/deploy/kubernetes/cloudsql.ts +2 -1
- package/src/deploy/kubernetes/deployJob.ts +19 -77
- package/src/deploy/kubernetes/index.ts +42 -1
- package/src/deploy/kubernetes/kubeEnv.ts +48 -0
- package/src/deploy/kubernetes/kubeValues.ts +82 -0
- package/src/deploy/kubernetes/mongodb.ts +104 -7
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
- package/src/deploy/types/base.ts +17 -0
- package/src/deploy/types/custom.ts +24 -0
- package/src/deploy/types/dockerTag.ts +12 -0
- package/src/deploy/types/googleCloudRun.ts +79 -0
- package/src/deploy/types/index.ts +28 -0
- package/src/deploy/types/kubernetes.ts +281 -0
- package/src/deploy/utils.ts +6 -2
- package/src/pipeline/createChildPipeline.test.ts +1 -1
- package/src/pipeline/createChildPipeline.ts +4 -4
- package/src/pipeline/createJobs.ts +32 -21
- package/src/pipeline/gitlab/makeGitlabJob.ts +3 -2
- package/src/pipeline/packageManager.ts +1 -1
- package/src/rules/index.ts +1 -1
- package/src/runner/index.ts +2 -1
- package/src/types/config.ts +8 -6
- package/src/types/context.ts +14 -2
- package/src/types/environmentContext.ts +26 -0
- package/src/types/gitlab-types.ts +1 -1
- package/src/types/jobs.ts +9 -2
- package/src/types/pipeline.ts +1 -1
- package/tsconfig.json +2 -0
- package/dist/deploy/types.js +0 -16
- package/src/deploy/types.ts +0 -189
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type DeployConfigBase = {
|
|
2
|
+
/**
|
|
3
|
+
* whether to deploy automatically or manual. If not defined, these rules apply:
|
|
4
|
+
* - prod: manual
|
|
5
|
+
* - all other envs: auto
|
|
6
|
+
*/
|
|
7
|
+
when?: "manual" | "auto";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* EXPERIMENTAL
|
|
11
|
+
* wait for other components to deploy first, before doing this deployment
|
|
12
|
+
*/
|
|
13
|
+
waitFor?: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type AllowUnknownProps<T extends Record<string, unknown>> = T &
|
|
17
|
+
Record<string, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DeployConfigBase } from "./base";
|
|
2
|
+
|
|
3
|
+
export type DeployConfigCustom = {
|
|
4
|
+
/**
|
|
5
|
+
* custom deploy types allow you to specify custom commands to deploy your app
|
|
6
|
+
*/
|
|
7
|
+
type: "custom";
|
|
8
|
+
/**
|
|
9
|
+
* whether the deploy script requires a docker image to be built
|
|
10
|
+
*/
|
|
11
|
+
requiresDocker: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* whether your custom script requires yarn install
|
|
14
|
+
*/
|
|
15
|
+
requiresYarnInstall?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* your custom script
|
|
18
|
+
*/
|
|
19
|
+
script: string[];
|
|
20
|
+
/**
|
|
21
|
+
* script to run to stop the environment
|
|
22
|
+
*/
|
|
23
|
+
stopScript?: string[];
|
|
24
|
+
} & DeployConfigBase;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DeployConfigBase } from "./base";
|
|
2
|
+
|
|
3
|
+
export type DeployConfigDockerTag = {
|
|
4
|
+
/**
|
|
5
|
+
* adds a custom tag on the repo to deploy it.
|
|
6
|
+
*
|
|
7
|
+
* only used in veloplus atm, generally not recommended to use
|
|
8
|
+
*/
|
|
9
|
+
type: "dockerTag";
|
|
10
|
+
|
|
11
|
+
tag: string;
|
|
12
|
+
} & DeployConfigBase;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { DeployConfigBase } from "./base";
|
|
2
|
+
|
|
3
|
+
export type Gcloudregion =
|
|
4
|
+
| "asia-east1"
|
|
5
|
+
| "asia-northeast1"
|
|
6
|
+
| "asia-northeast2"
|
|
7
|
+
| "europe-north1"
|
|
8
|
+
| "europe-southwest1"
|
|
9
|
+
| "europe-west1"
|
|
10
|
+
| "europe-west4"
|
|
11
|
+
| "europe-west8"
|
|
12
|
+
| "europe-west9"
|
|
13
|
+
| "me-west1"
|
|
14
|
+
| "us-central1"
|
|
15
|
+
| "us-east1"
|
|
16
|
+
| "us-east4"
|
|
17
|
+
| "us-east5"
|
|
18
|
+
| "us-south1"
|
|
19
|
+
| "us-west1"
|
|
20
|
+
| "asia-east2"
|
|
21
|
+
| "asia-northeast3"
|
|
22
|
+
| "asia-southeast1"
|
|
23
|
+
| "asia-southeast2"
|
|
24
|
+
| "asia-south1"
|
|
25
|
+
| "asia-south2"
|
|
26
|
+
| "australia-southeast1"
|
|
27
|
+
| "australia-southeast2"
|
|
28
|
+
| "europe-central2"
|
|
29
|
+
| "europe-west2"
|
|
30
|
+
| "europe-west3"
|
|
31
|
+
| "europe-west6"
|
|
32
|
+
| "northamerica-northeast1"
|
|
33
|
+
| "northamerica-northeast2"
|
|
34
|
+
| "southamerica-east1"
|
|
35
|
+
| "southamerica-west1"
|
|
36
|
+
| "us-west2"
|
|
37
|
+
| "us-west3"
|
|
38
|
+
| "us-west4";
|
|
39
|
+
|
|
40
|
+
export type DeployConfigCloudRunBase = {
|
|
41
|
+
/**
|
|
42
|
+
* the google cloud porject id
|
|
43
|
+
*/
|
|
44
|
+
projectId: string;
|
|
45
|
+
/**
|
|
46
|
+
* the region. Set to europe-west6 for switzerland
|
|
47
|
+
*/
|
|
48
|
+
region: Gcloudregion;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* command / entrypoint, fallsback to buildConfig.startcommand
|
|
52
|
+
*/
|
|
53
|
+
command?: string;
|
|
54
|
+
} & DeployConfigBase;
|
|
55
|
+
export type DeployConfigCloudRunService = {
|
|
56
|
+
/**
|
|
57
|
+
* EXPERIMENTAL cloud run deployment.
|
|
58
|
+
*
|
|
59
|
+
* This will deploy a cloud run service.
|
|
60
|
+
*
|
|
61
|
+
* Requires that cloud run is enabled on the project, as well as cloud run api and artifacts registry.
|
|
62
|
+
*/
|
|
63
|
+
type: "google-cloudrun";
|
|
64
|
+
} & DeployConfigCloudRunBase;
|
|
65
|
+
|
|
66
|
+
export type DeployConfigCloudRunJob = {
|
|
67
|
+
/**
|
|
68
|
+
* EXPERIMENTAL cloud run job.
|
|
69
|
+
*
|
|
70
|
+
* This will deploy a cloud run job. This does not do much currently, but will be later used for cronjobs
|
|
71
|
+
*
|
|
72
|
+
* Requires that cloud run is enabled on the project, as well as cloud run api and artifacts registry.
|
|
73
|
+
*/
|
|
74
|
+
type: "google-cloudrun-job";
|
|
75
|
+
} & DeployConfigCloudRunBase;
|
|
76
|
+
|
|
77
|
+
export type DeployConfigCloudRun =
|
|
78
|
+
| DeployConfigCloudRunService
|
|
79
|
+
| DeployConfigCloudRunJob;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DeployConfigCustom } from "./custom";
|
|
2
|
+
import type { DeployConfigDockerTag } from "./dockerTag";
|
|
3
|
+
import type { DeployConfigCloudRun } from "./googleCloudRun";
|
|
4
|
+
import type { DeployConfigKubernetes } from "./kubernetes";
|
|
5
|
+
|
|
6
|
+
export * from "./custom";
|
|
7
|
+
export * from "./googleCloudRun";
|
|
8
|
+
export * from "./kubernetes";
|
|
9
|
+
export * from "./dockerTag";
|
|
10
|
+
|
|
11
|
+
export type DeployConfig =
|
|
12
|
+
| DeployConfigKubernetes
|
|
13
|
+
| DeployConfigCustom
|
|
14
|
+
| DeployConfigCloudRun
|
|
15
|
+
| DeployConfigDockerTag;
|
|
16
|
+
|
|
17
|
+
export type DeployConfigType = DeployConfig["type"];
|
|
18
|
+
export type DeployConfigGeneric<T extends DeployConfigType> = Extract<
|
|
19
|
+
DeployConfig,
|
|
20
|
+
{ type: T }
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export const isOfDeployType = <T extends Array<DeployConfigType>>(
|
|
24
|
+
t: DeployConfig | false,
|
|
25
|
+
...types: T
|
|
26
|
+
): t is Extract<DeployConfig, { type: T[number] }> => {
|
|
27
|
+
return t && types.includes(t.type);
|
|
28
|
+
};
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type { AllowUnknownProps, DeployConfigBase } from "./base";
|
|
2
|
+
|
|
3
|
+
export type DeployConfigKubernetesClusterGCloud = {
|
|
4
|
+
type: "gcloud";
|
|
5
|
+
/**
|
|
6
|
+
* gcoud name of the cluster
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* google cloud project id
|
|
11
|
+
*/
|
|
12
|
+
projectId: string;
|
|
13
|
+
/**
|
|
14
|
+
* region
|
|
15
|
+
*/
|
|
16
|
+
region: string;
|
|
17
|
+
/**
|
|
18
|
+
* domain of the cluster, for canonical domains without custom host (e.g. review and dev apps)
|
|
19
|
+
*/
|
|
20
|
+
domainCanonical?: string;
|
|
21
|
+
};
|
|
22
|
+
export type DeployConfigKubernetesCluster = DeployConfigKubernetesClusterGCloud; // currently only this
|
|
23
|
+
|
|
24
|
+
export type KubernetesAutoscaleMetricResourceTarget =
|
|
25
|
+
| {
|
|
26
|
+
type: "Utilization";
|
|
27
|
+
averageUtilization: number;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
type: "AverageValue";
|
|
31
|
+
averageValue: number | string;
|
|
32
|
+
};
|
|
33
|
+
export type KubernetesAutoscaleMetric = {
|
|
34
|
+
type: "Resource";
|
|
35
|
+
resource: {
|
|
36
|
+
name: "cpu" | "memory";
|
|
37
|
+
target: KubernetesAutoscaleMetricResourceTarget;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type KubernetesAutoscale = {
|
|
41
|
+
minReplicas: number;
|
|
42
|
+
maxReplicas: number;
|
|
43
|
+
/**
|
|
44
|
+
* declare a number of metrics (at least one). Usually you would use cpu as a metric
|
|
45
|
+
*/
|
|
46
|
+
metrics: KubernetesAutoscaleMetric[];
|
|
47
|
+
};
|
|
48
|
+
export type KubernetesResourcesDef = {
|
|
49
|
+
limits?: {
|
|
50
|
+
cpu?: string;
|
|
51
|
+
memory?: string;
|
|
52
|
+
};
|
|
53
|
+
requests?: {
|
|
54
|
+
cpu?: string;
|
|
55
|
+
memory?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
type KubernetesHealthDef = {
|
|
59
|
+
httpGet?: {
|
|
60
|
+
path?: string;
|
|
61
|
+
port?: number;
|
|
62
|
+
httpHeaders?: {
|
|
63
|
+
name: string;
|
|
64
|
+
value: string;
|
|
65
|
+
}[];
|
|
66
|
+
failureThreshold?: number;
|
|
67
|
+
timeoutSeconds?: number;
|
|
68
|
+
periodSeconds?: number;
|
|
69
|
+
successThreshold?: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type KubernetesUpdateStrategy = {
|
|
73
|
+
rollingUpdate: {
|
|
74
|
+
/**
|
|
75
|
+
* how many pods can be created additionally to the target number
|
|
76
|
+
* can be absolute number or percentage.
|
|
77
|
+
* defaults to 1 (kube default is 25%)
|
|
78
|
+
*/
|
|
79
|
+
maxSurge: number | string;
|
|
80
|
+
/**
|
|
81
|
+
* how many pods are allowed to be unavailable
|
|
82
|
+
* can be absolute number or percentage
|
|
83
|
+
* defaults to 0 (kube default is 25%)
|
|
84
|
+
*/
|
|
85
|
+
maxUnavailable: number | string;
|
|
86
|
+
};
|
|
87
|
+
type: "RollingUpdate";
|
|
88
|
+
};
|
|
89
|
+
export type KubernetesWorkerDef = {
|
|
90
|
+
enabled: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* which command to run. defaults to `yarn start`
|
|
93
|
+
*/
|
|
94
|
+
command?: string;
|
|
95
|
+
resources?: KubernetesResourcesDef;
|
|
96
|
+
service?: {
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type DeployConfigMongodbBase = {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
dbName?: string;
|
|
104
|
+
persistence?: {
|
|
105
|
+
/**
|
|
106
|
+
* set premium-rwo for ssd
|
|
107
|
+
*/
|
|
108
|
+
storageClass?: "standard-rwo" | "premium-rwo";
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* size of the volume, defaults to 8Gi
|
|
112
|
+
*/
|
|
113
|
+
size?: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type DeployConfigMongodbStandalone = {
|
|
118
|
+
architecture: "standalone";
|
|
119
|
+
};
|
|
120
|
+
export type DeployConfigMongodbReplicaset = {
|
|
121
|
+
architecture: "replicaset";
|
|
122
|
+
/**
|
|
123
|
+
* defaults to 2
|
|
124
|
+
*/
|
|
125
|
+
replicaCount?: number;
|
|
126
|
+
};
|
|
127
|
+
export type DeployConfigMongodb = DeployConfigMongodbBase &
|
|
128
|
+
(DeployConfigMongodbStandalone | DeployConfigMongodbReplicaset);
|
|
129
|
+
|
|
130
|
+
export type DeployConfigKubernetesValues = AllowUnknownProps<{
|
|
131
|
+
/**
|
|
132
|
+
* enable cloudsql db. Currently you have to manually set it up
|
|
133
|
+
*/
|
|
134
|
+
cloudsql?: {
|
|
135
|
+
enabled: boolean;
|
|
136
|
+
instanceId?: string;
|
|
137
|
+
projectId?: string;
|
|
138
|
+
region?: string;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* enable mongodb. The mongodb is deployed using a helm chart.
|
|
142
|
+
* See https://github.com/bitnami/charts/tree/master/bitnami/mongodb
|
|
143
|
+
*/
|
|
144
|
+
mongodb?: DeployConfigMongodb;
|
|
145
|
+
/**
|
|
146
|
+
* enable mailhog. Mailhog is a virtual mail server that catches all outgoing mailsl and show them in a mailbox.
|
|
147
|
+
* This is great for development as it prevents to accidentially send out real emails and helps with debugging outgoing mails.
|
|
148
|
+
*
|
|
149
|
+
* It will automaticaly inject a MAIL_URL env var.
|
|
150
|
+
*
|
|
151
|
+
* Turn it of for production.
|
|
152
|
+
*/
|
|
153
|
+
mailhog?: {
|
|
154
|
+
enabled: boolean;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* post-install/upgrade jobs. These use the app image and have all env vars available.
|
|
158
|
+
* Typically used for migrations and seeds
|
|
159
|
+
*/
|
|
160
|
+
jobs?: Record<
|
|
161
|
+
string,
|
|
162
|
+
AllowUnknownProps<{
|
|
163
|
+
/**
|
|
164
|
+
* the command to execute
|
|
165
|
+
*/
|
|
166
|
+
command: string;
|
|
167
|
+
/**
|
|
168
|
+
* comma-separated list of helm hooks, see https://helm.sh/docs/topics/charts_hooks/
|
|
169
|
+
*
|
|
170
|
+
* defaults to post-install,post-upgrade
|
|
171
|
+
*/
|
|
172
|
+
hook?: string;
|
|
173
|
+
}>
|
|
174
|
+
>;
|
|
175
|
+
/**
|
|
176
|
+
* cronjobs that run periodically. These use the app image have all env vars available.
|
|
177
|
+
*/
|
|
178
|
+
cronjobs?: Record<
|
|
179
|
+
string,
|
|
180
|
+
AllowUnknownProps<{
|
|
181
|
+
schedule: string;
|
|
182
|
+
command: string;
|
|
183
|
+
concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
|
|
184
|
+
}>
|
|
185
|
+
>;
|
|
186
|
+
/**
|
|
187
|
+
* configuration for the application ("Deployment" in kubernetes)
|
|
188
|
+
*/
|
|
189
|
+
application?:
|
|
190
|
+
| false
|
|
191
|
+
| AllowUnknownProps<{
|
|
192
|
+
/**
|
|
193
|
+
* enable, disable app deployment, defaults to true
|
|
194
|
+
*/
|
|
195
|
+
enabled?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* redirects
|
|
198
|
+
*/
|
|
199
|
+
redirects?: AllowUnknownProps<{ host: string }>[];
|
|
200
|
+
/**
|
|
201
|
+
* Host aliases
|
|
202
|
+
*/
|
|
203
|
+
hostAliases?: string[];
|
|
204
|
+
/**
|
|
205
|
+
* how many pods will be started
|
|
206
|
+
*/
|
|
207
|
+
replicas?: number;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* autoscale the pods horizontally
|
|
211
|
+
*/
|
|
212
|
+
autoscale?: KubernetesAutoscale;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* the update strategy, see https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment
|
|
216
|
+
*/
|
|
217
|
+
updateStrategy?: KubernetesUpdateStrategy;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* kubernetes resources
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
resources?: KubernetesResourcesDef;
|
|
224
|
+
healthRoute?: string;
|
|
225
|
+
startupProbe?: KubernetesHealthDef;
|
|
226
|
+
readinessProbe?: KubernetesHealthDef;
|
|
227
|
+
livenessProbe?: KubernetesHealthDef;
|
|
228
|
+
/**
|
|
229
|
+
* specify a worker. A worker is a separate deployment that runs continously in the background.
|
|
230
|
+
* The worker pod can use the same entry point as the app or a different one (specify command).
|
|
231
|
+
* It has the same environment variables as the application and an additional IS_WORKER="true" variable
|
|
232
|
+
*/
|
|
233
|
+
worker?: KubernetesWorkerDef;
|
|
234
|
+
}>;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* load secrets from other components.
|
|
238
|
+
* Use this only in cases where the secret is not known on pipeline-time
|
|
239
|
+
* and only if the component is also in the same cluster.
|
|
240
|
+
*
|
|
241
|
+
* a typical case is reusing mongo_url from other component
|
|
242
|
+
*
|
|
243
|
+
* also make sure that the other component deploys first
|
|
244
|
+
*
|
|
245
|
+
* in all other cases use normal env var handling
|
|
246
|
+
*/
|
|
247
|
+
secretsFromOtherComponent?: {
|
|
248
|
+
[envVar: string]: string;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* map another services internal endpoint into a env var.
|
|
253
|
+
*/
|
|
254
|
+
mapServiceUrlToEnv?: {
|
|
255
|
+
[envVar: string]: string;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Mount secrets as files in the filesystem.
|
|
259
|
+
* These secrets are still available as env vars, but will contain the path of the file instead
|
|
260
|
+
*
|
|
261
|
+
* @deprecated this will be removed in the future, because its very niche and not used
|
|
262
|
+
*/
|
|
263
|
+
secretsAsFile?: string[];
|
|
264
|
+
}>;
|
|
265
|
+
|
|
266
|
+
export type DeployConfigKubernetes = {
|
|
267
|
+
type: "kubernetes";
|
|
268
|
+
/**
|
|
269
|
+
* cluster config to use.
|
|
270
|
+
*/
|
|
271
|
+
cluster: DeployConfigKubernetesCluster;
|
|
272
|
+
/**
|
|
273
|
+
* prints out debug info (helm --debug)
|
|
274
|
+
*/
|
|
275
|
+
debug?: boolean;
|
|
276
|
+
additionalHelmArgs?: string[];
|
|
277
|
+
/**
|
|
278
|
+
* values to configure the app
|
|
279
|
+
*/
|
|
280
|
+
values?: DeployConfigKubernetesValues;
|
|
281
|
+
} & DeployConfigBase;
|
package/src/deploy/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Config, Context } from "../types";
|
|
2
|
-
import { DeployConfigKubernetesCluster
|
|
1
|
+
import type { Config, Context } from "../types";
|
|
2
|
+
import type { DeployConfigKubernetesCluster } from "./types";
|
|
3
|
+
import { isOfDeployType } from "./types";
|
|
3
4
|
|
|
4
5
|
export const getFullKubernetesClusterName = (
|
|
5
6
|
cluster: DeployConfigKubernetesCluster
|
|
@@ -22,6 +23,9 @@ export const contextIsStoppable = (context: Context) => {
|
|
|
22
23
|
return true;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
if (isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
25
29
|
if (isOfDeployType(deployConfig, "custom") && deployConfig.stopScript) {
|
|
26
30
|
return true;
|
|
27
31
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getAllEnvsByTrigger, getAllEnvsInAllComponents } from "../config";
|
|
2
2
|
import { RULES_ALWAYS } from "../rules";
|
|
3
3
|
import { getRunnerImage } from "../runner";
|
|
4
|
-
import { GitlabPipeline, Pipeline, PipelineJob, PipelineType } from "../types";
|
|
5
|
-
import { Config, PipelineTrigger } from "../types/config";
|
|
4
|
+
import type { GitlabPipeline, Pipeline, PipelineJob, PipelineType } from "../types";
|
|
5
|
+
import type { Config, PipelineTrigger } from "../types/config";
|
|
6
|
+
import { BASE_STAGES } from "../types/jobs";
|
|
6
7
|
import { createJobs } from "./createJobs";
|
|
7
8
|
|
|
8
|
-
const baseStages = ["setup", "test", "build", "deploy", "verify", "stop"];
|
|
9
9
|
export const createChildPipeline = async <T extends PipelineType>(
|
|
10
10
|
type: T,
|
|
11
11
|
trigger: PipelineTrigger,
|
|
@@ -30,7 +30,7 @@ export const createChildPipeline = async <T extends PipelineType>(
|
|
|
30
30
|
// this is just so that it looks nicer in gitlab and makes running mutliple manual tasks more easy to use
|
|
31
31
|
|
|
32
32
|
const allEnvs = getAllEnvsInAllComponents(config);
|
|
33
|
-
const stages =
|
|
33
|
+
const stages = BASE_STAGES.reduce<string[]>(
|
|
34
34
|
(acc, baseStage) => [
|
|
35
35
|
...acc,
|
|
36
36
|
baseStage,
|
|
@@ -3,10 +3,10 @@ import { isFunction, isObject } from "lodash";
|
|
|
3
3
|
import { BUILD_TYPES } from "../build";
|
|
4
4
|
import { createContext } from "../context";
|
|
5
5
|
import { DEPLOY_TYPES } from "../deploy";
|
|
6
|
-
import { PipelineJob, PipelineType } from "../types";
|
|
7
|
-
import { Config, PipelineTrigger } from "../types/config";
|
|
8
|
-
import { CommitInfo, Context } from "../types/context";
|
|
9
|
-
import { CatladderJob } from "../types/jobs";
|
|
6
|
+
import type { PipelineJob, PipelineType } from "../types";
|
|
7
|
+
import type { Config, PipelineTrigger } from "../types/config";
|
|
8
|
+
import type { CommitInfo, Context } from "../types/context";
|
|
9
|
+
import type { CatladderJob } from "../types/jobs";
|
|
10
10
|
import { notNil } from "../utils";
|
|
11
11
|
import { makeGitlabJob } from "./gitlab/makeGitlabJob";
|
|
12
12
|
import { getPackageManagerInfo } from "./packageManager";
|
|
@@ -77,22 +77,33 @@ const replaceReferences = (
|
|
|
77
77
|
): CatladderJob<string> => {
|
|
78
78
|
const stage =
|
|
79
79
|
job.envMode === "stagePerEnv" ? `${job.stage} ${env}` : job.stage;
|
|
80
|
+
|
|
81
|
+
const needsFromNeeds: CatladderJob["needs"] = job.needs?.map((n) =>
|
|
82
|
+
isObject(n)
|
|
83
|
+
? {
|
|
84
|
+
job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
|
|
85
|
+
artifacts: n.artifacts,
|
|
86
|
+
}
|
|
87
|
+
: getFullReferencedJobName(n, componentName, env, allRawJobs)
|
|
88
|
+
);
|
|
89
|
+
const needsFromOtherComponents: CatladderJob["needs"] =
|
|
90
|
+
job.needsOtherComponent?.map((other) => ({
|
|
91
|
+
artifacts: other.artifacts,
|
|
92
|
+
job: getFullReferencedJobName(
|
|
93
|
+
other.job,
|
|
94
|
+
other.componentName,
|
|
95
|
+
env,
|
|
96
|
+
allRawJobs
|
|
97
|
+
),
|
|
98
|
+
}));
|
|
99
|
+
const needs = [
|
|
100
|
+
...(needsFromNeeds ?? []),
|
|
101
|
+
...(needsFromOtherComponents ?? []),
|
|
102
|
+
];
|
|
80
103
|
return {
|
|
81
104
|
...job,
|
|
82
105
|
stage,
|
|
83
|
-
needs
|
|
84
|
-
isObject(n)
|
|
85
|
-
? {
|
|
86
|
-
job: getFullReferencedJobName(
|
|
87
|
-
n.job,
|
|
88
|
-
componentName,
|
|
89
|
-
env,
|
|
90
|
-
allRawJobs
|
|
91
|
-
),
|
|
92
|
-
artifacts: n.artifacts,
|
|
93
|
-
}
|
|
94
|
-
: getFullReferencedJobName(n, componentName, env, allRawJobs)
|
|
95
|
-
),
|
|
106
|
+
needs,
|
|
96
107
|
environment: job.environment?.on_stop
|
|
97
108
|
? {
|
|
98
109
|
...job.environment,
|
|
@@ -155,8 +166,8 @@ export const createJobs = async <T extends PipelineType>(
|
|
|
155
166
|
|
|
156
167
|
const packageManagerInfo = await getPackageManagerInfo(config, componentName);
|
|
157
168
|
|
|
158
|
-
return envs.reduce((acc, env) => {
|
|
159
|
-
const context = createContext(
|
|
169
|
+
return envs.reduce(async (acc, env) => {
|
|
170
|
+
const context = await createContext(
|
|
160
171
|
config,
|
|
161
172
|
componentName,
|
|
162
173
|
env,
|
|
@@ -166,7 +177,7 @@ export const createJobs = async <T extends PipelineType>(
|
|
|
166
177
|
const jobs = addStageNeeds(createRawJobs(context));
|
|
167
178
|
|
|
168
179
|
const result = {
|
|
169
|
-
...acc,
|
|
180
|
+
...(await acc),
|
|
170
181
|
...jobs.reduce<Record<string, PipelineJob<T>>>((acc, job) => {
|
|
171
182
|
const jobWithResolvedReferences = replaceReferences(
|
|
172
183
|
job,
|
|
@@ -188,7 +199,7 @@ export const createJobs = async <T extends PipelineType>(
|
|
|
188
199
|
};
|
|
189
200
|
}
|
|
190
201
|
throw new Error("not supported");
|
|
191
|
-
}, {}),
|
|
202
|
+
}, await Promise.resolve({})),
|
|
192
203
|
};
|
|
193
204
|
return result;
|
|
194
205
|
}, {});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BASE_RETRY } from "../../defaults";
|
|
2
|
-
import { GitlabJobDef } from "../../types";
|
|
3
|
-
import { CatladderJob } from "../../types/jobs";
|
|
2
|
+
import type { GitlabJobDef } from "../../types";
|
|
3
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
4
4
|
|
|
5
5
|
export const makeGitlabJob = ({
|
|
6
6
|
envMode,
|
|
7
7
|
needsStages,
|
|
8
|
+
needsOtherComponent,
|
|
8
9
|
name,
|
|
9
10
|
...rest
|
|
10
11
|
}: CatladderJob<string>): GitlabJobDef => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
|
-
import { Config, PackageManagerInfo } from "../types";
|
|
2
|
+
import type { Config, PackageManagerInfo } from "../types";
|
|
3
3
|
import { pathEqual } from "path-equal";
|
|
4
4
|
import memoizee from "memoizee";
|
|
5
5
|
import { join } from "path";
|
package/src/rules/index.ts
CHANGED
package/src/runner/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { PIPELINE_IMAGE_TAG, DOCKER_REGISTRY } from "../constants";
|
|
2
2
|
|
|
3
|
-
type RunnerImageName =
|
|
3
|
+
export type RunnerImageName =
|
|
4
4
|
| "jobs-default"
|
|
5
5
|
| "jobs-meteor"
|
|
6
6
|
| "jobs-testing-chrome"
|
|
7
7
|
| "kubernetes"
|
|
8
8
|
| "base-pipeline"
|
|
9
9
|
| "docker-build"
|
|
10
|
+
| "gcloud"
|
|
10
11
|
| "semantic-release";
|
|
11
12
|
export const getRunnerImage = (imageName: RunnerImageName) =>
|
|
12
13
|
DOCKER_REGISTRY + "/" + imageName + ":" + PIPELINE_IMAGE_TAG;
|
package/src/types/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BuildConfig } from "../build/types";
|
|
2
|
-
import { DeployConfig } from "../deploy/types";
|
|
3
|
-
import { PartialDeep } from "type-fest";
|
|
4
|
-
import { CatladderJob } from "./jobs";
|
|
5
|
-
import { Context } from "./context";
|
|
1
|
+
import type { BuildConfig } from "../build/types";
|
|
2
|
+
import type { DeployConfig } from "../deploy/types";
|
|
3
|
+
import type { PartialDeep } from "type-fest";
|
|
4
|
+
import type { CatladderJob } from "./jobs";
|
|
5
|
+
import type { Context } from "./context";
|
|
6
6
|
export type PipelineTrigger = "mainBranch" | "mr" | "taggedRelease";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -11,7 +11,7 @@ export type PipelineTrigger = "mainBranch" | "mr" | "taggedRelease";
|
|
|
11
11
|
*/
|
|
12
12
|
export const ENV_TYPES = {
|
|
13
13
|
dev: {
|
|
14
|
-
triggers: ["mainBranch"
|
|
14
|
+
triggers: ["mainBranch"],
|
|
15
15
|
},
|
|
16
16
|
review: {
|
|
17
17
|
triggers: ["mr"],
|
|
@@ -104,6 +104,8 @@ export type EnvConfig<E extends EnvType = EnvType> = {
|
|
|
104
104
|
host?: string;
|
|
105
105
|
} & PartialDeep<DefaultEnvConfig>;
|
|
106
106
|
|
|
107
|
+
export type EnvConfigWithComponent = EnvConfig<EnvType> & ComponentConfig;
|
|
108
|
+
|
|
107
109
|
export type Env = {
|
|
108
110
|
/**
|
|
109
111
|
* local is a special env that is only used in local development
|