@catladder/pipeline 0.0.0-tagged-release-2fffd3dd → 0.0.0-waitfor-deploy-e64a33ba
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/build/base/constants.js +2 -2
- package/dist/build/base/createBuildJob.d.ts +4 -2
- package/dist/build/base/createBuildJob.js +18 -17
- package/dist/build/base/getBuildInfo.d.ts +2 -0
- package/dist/build/base/getBuildInfo.js +12 -0
- package/dist/build/docker.d.ts +29 -4
- package/dist/build/docker.js +74 -23
- package/dist/build/index.d.ts +2 -2
- package/dist/build/index.js +1 -1
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +27 -11
- package/dist/build/node/cache.d.ts +3 -1
- package/dist/build/node/cache.js +34 -6
- package/dist/build/node/constants.js +2 -2
- package/dist/build/node/index.d.ts +4 -4
- package/dist/build/node/meteor.d.ts +2 -2
- package/dist/build/node/meteor.js +7 -23
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +22 -30
- package/dist/build/node/yarn.d.ts +5 -0
- package/dist/build/node/yarn.js +51 -3
- package/dist/build/tests/storybook.test.js +17 -24
- package/dist/build/types.d.ts +13 -0
- package/dist/catladder-gitlab.js +42 -9
- package/dist/config/configruedEnvs.test.js +12 -3
- package/dist/config/readConfig.d.ts +5 -1
- package/dist/config/readConfig.js +20 -5
- package/dist/constants.js +1 -1
- package/dist/context/index.d.ts +4 -3
- package/dist/context/index.js +56 -43
- package/dist/context/resolveReferences.d.ts +6 -0
- package/dist/context/resolveReferences.js +93 -0
- package/dist/context/resolveReferences.test.d.ts +1 -0
- package/dist/context/resolveReferences.test.js +141 -0
- package/dist/deploy/base.d.ts +3 -4
- package/dist/deploy/base.js +55 -35
- package/dist/deploy/custom/deployJob.d.ts +3 -0
- package/dist/deploy/custom/deployJob.js +65 -0
- package/dist/deploy/custom/index.d.ts +1 -0
- package/dist/deploy/custom/index.js +22 -0
- package/dist/deploy/index.d.ts +5 -3
- package/dist/deploy/index.js +12 -0
- package/dist/deploy/kubernetes/cloudsql.js +1 -1
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +74 -42
- package/dist/deploy/kubernetes/mongodb.js +1 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +87 -0
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +39 -0
- package/dist/deploy/types.d.ts +194 -84
- package/dist/deploy/utils.d.ts +5 -0
- package/dist/deploy/utils.js +36 -0
- package/dist/pipeline/createChildPipeline.d.ts +2 -8
- package/dist/pipeline/createChildPipeline.js +24 -15
- package/dist/pipeline/createChildPipeline.test.js +10 -15
- package/dist/pipeline/createJobs.d.ts +2 -2
- package/dist/pipeline/createJobs.js +95 -33
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +8 -0
- package/dist/pipeline/gitlab/makeGitlabJob.js +45 -0
- package/dist/pipeline/packageManager.d.ts +2 -0
- package/dist/pipeline/{yarnInfo.js → packageManager.js} +69 -8
- package/dist/runner/index.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +87 -1
- package/dist/types/context.d.ts +19 -8
- package/dist/types/gitlab-types.d.ts +10 -22
- package/dist/types/gitlab-types.js +1 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +3 -1
- package/dist/types/jobs.d.ts +80 -0
- package/dist/types/jobs.js +5 -0
- package/dist/types/pipeline.d.ts +4 -0
- package/dist/types/pipeline.js +3 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +45 -2
- package/package.json +1 -3
- package/src/build/base/constants.ts +2 -2
- package/src/build/base/createBuildJob.ts +31 -34
- package/src/build/base/getBuildInfo.ts +7 -0
- package/src/build/docker.ts +75 -35
- package/src/build/index.ts +4 -3
- package/src/build/node/buildJob.ts +46 -24
- package/src/build/node/cache.ts +31 -6
- package/src/build/node/constants.ts +2 -2
- package/src/build/node/index.ts +4 -4
- package/src/build/node/meteor.ts +12 -18
- package/src/build/node/testJob.ts +35 -40
- package/src/build/node/yarn.ts +25 -4
- package/src/build/tests/storybook.test.ts +10 -2
- package/src/build/types.ts +12 -0
- package/src/catladder-gitlab.ts +12 -7
- package/src/config/configruedEnvs.test.ts +10 -3
- package/src/config/readConfig.ts +18 -6
- package/src/context/index.ts +90 -52
- package/src/context/resolveReferences.test.ts +158 -0
- package/src/context/resolveReferences.ts +66 -0
- package/src/deploy/base.ts +73 -47
- package/src/deploy/custom/deployJob.ts +23 -0
- package/src/deploy/custom/index.ts +1 -0
- package/src/deploy/index.ts +10 -4
- package/src/deploy/kubernetes/cloudsql.ts +3 -4
- package/src/deploy/kubernetes/deployJob.ts +85 -45
- package/src/deploy/kubernetes/mongodb.ts +1 -3
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +34 -0
- package/src/deploy/types.ts +177 -42
- package/src/deploy/utils.ts +30 -0
- package/src/pipeline/createChildPipeline.test.ts +8 -1
- package/src/pipeline/createChildPipeline.ts +23 -18
- package/src/pipeline/createJobs.ts +104 -56
- package/src/pipeline/gitlab/makeGitlabJob.ts +16 -0
- package/src/pipeline/packageManager.ts +99 -0
- package/src/runner/index.ts +3 -1
- package/src/types/config.ts +79 -1
- package/src/types/context.ts +18 -5
- package/src/types/gitlab-types.ts +10 -30
- package/src/types/index.ts +1 -0
- package/src/types/jobs.ts +94 -0
- package/src/types/pipeline.ts +11 -0
- package/src/utils/index.ts +10 -1
- package/dist/pipeline/yarnInfo.d.ts +0 -2
- package/src/pipeline/yarnInfo.ts +0 -54
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export declare const processSecretsAsFiles: <T extends {
|
|
2
|
+
env: {
|
|
3
|
+
secret: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
} & {
|
|
6
|
+
cloudsql?: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
instanceId?: string | undefined;
|
|
9
|
+
projectId?: string | undefined;
|
|
10
|
+
region?: string | undefined;
|
|
11
|
+
} | undefined;
|
|
12
|
+
mongodb?: ({
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
} & Record<string, unknown>) | undefined;
|
|
15
|
+
mailhog?: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
} | undefined;
|
|
18
|
+
jobs?: Record<string, {
|
|
19
|
+
command: string;
|
|
20
|
+
} & Record<string, unknown>> | undefined;
|
|
21
|
+
cronjobs?: Record<string, {
|
|
22
|
+
schedule: string;
|
|
23
|
+
command: string;
|
|
24
|
+
concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
|
|
25
|
+
} & Record<string, unknown>> | undefined;
|
|
26
|
+
application?: ({
|
|
27
|
+
redirects?: ({
|
|
28
|
+
host: string;
|
|
29
|
+
} & Record<string, unknown>)[] | undefined;
|
|
30
|
+
replicas?: number | undefined;
|
|
31
|
+
autoscale?: import("../types").KubernetesAutoscale | undefined;
|
|
32
|
+
resources?: {
|
|
33
|
+
limits?: {
|
|
34
|
+
cpu?: string | undefined;
|
|
35
|
+
memory?: string | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
requests?: {
|
|
38
|
+
cpu?: string | undefined;
|
|
39
|
+
memory?: string | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
healthRoute?: string | undefined;
|
|
43
|
+
startupProbe?: {
|
|
44
|
+
httpGet?: {
|
|
45
|
+
path?: string | undefined;
|
|
46
|
+
port?: number | undefined;
|
|
47
|
+
httpHeaders?: {
|
|
48
|
+
name: string;
|
|
49
|
+
value: string;
|
|
50
|
+
}[] | undefined;
|
|
51
|
+
failureThreshold?: number | undefined;
|
|
52
|
+
timeoutSeconds?: number | undefined;
|
|
53
|
+
periodSeconds?: number | undefined;
|
|
54
|
+
successThreshold?: number | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
readinessProbe?: {
|
|
58
|
+
httpGet?: {
|
|
59
|
+
path?: string | undefined;
|
|
60
|
+
port?: number | undefined;
|
|
61
|
+
httpHeaders?: {
|
|
62
|
+
name: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}[] | undefined;
|
|
65
|
+
failureThreshold?: number | undefined;
|
|
66
|
+
timeoutSeconds?: number | undefined;
|
|
67
|
+
periodSeconds?: number | undefined;
|
|
68
|
+
successThreshold?: number | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
livenessProbe?: {
|
|
72
|
+
httpGet?: {
|
|
73
|
+
path?: string | undefined;
|
|
74
|
+
port?: number | undefined;
|
|
75
|
+
httpHeaders?: {
|
|
76
|
+
name: string;
|
|
77
|
+
value: string;
|
|
78
|
+
}[] | undefined;
|
|
79
|
+
failureThreshold?: number | undefined;
|
|
80
|
+
timeoutSeconds?: number | undefined;
|
|
81
|
+
periodSeconds?: number | undefined;
|
|
82
|
+
successThreshold?: number | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
} & Record<string, unknown>) | undefined;
|
|
86
|
+
secretsAsFile?: string[] | undefined;
|
|
87
|
+
} & Record<string, unknown>>(values: T) => T;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.processSecretsAsFiles = void 0;
|
|
19
|
+
|
|
20
|
+
var lodash_1 = require("lodash");
|
|
21
|
+
|
|
22
|
+
var processSecretsAsFiles = function (values) {
|
|
23
|
+
if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
|
|
24
|
+
return values;
|
|
25
|
+
} // the initial idea was that we "shadow" secrets that we mount as files,
|
|
26
|
+
// but there is a weird kubernetes issue with that (https://github.com/kubernetes/kubernetes/issues/46861),
|
|
27
|
+
// 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
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
return __assign(__assign({}, values), {
|
|
31
|
+
env: __assign(__assign({}, values.env), {
|
|
32
|
+
secret: __assign(__assign({}, (0, lodash_1.omit)(values.env.secret, values.secretsAsFile)), Object.fromEntries(values.secretsAsFile.map(function (key) {
|
|
33
|
+
return [key + "_content", values.env.secret[key]];
|
|
34
|
+
})))
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.processSecretsAsFiles = processSecretsAsFiles;
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -1,92 +1,202 @@
|
|
|
1
|
-
export declare type DeployConfigBase = {
|
|
1
|
+
export declare 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
|
+
* EXPERIMENTAL
|
|
10
|
+
* wait for other components to deploy first, before doing this deployment
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
waitFor?: string[];
|
|
14
|
+
};
|
|
2
15
|
declare type AllowUnknownProps<T extends Record<string, unknown>> = T & Record<string, unknown>;
|
|
16
|
+
export declare type DeployConfigKubernetesClusterGCloud = {
|
|
17
|
+
type: "gcloud";
|
|
18
|
+
/**
|
|
19
|
+
* gcoud name of the cluster
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
name: string;
|
|
23
|
+
/**
|
|
24
|
+
* google cloud project id
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
projectId: string;
|
|
28
|
+
/**
|
|
29
|
+
* region
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
region: string;
|
|
33
|
+
/**
|
|
34
|
+
* domain of the cluster, for canonical domains without custom host (e.g. review and dev apps)
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
domainCanonical?: string;
|
|
38
|
+
};
|
|
39
|
+
export declare type DeployConfigKubernetesCluster = DeployConfigKubernetesClusterGCloud;
|
|
40
|
+
export declare type KubernetesAutoscaleMetricResourceTarget = {
|
|
41
|
+
type: "Utilization";
|
|
42
|
+
averageUtilization: number;
|
|
43
|
+
} | {
|
|
44
|
+
type: "AverageValue";
|
|
45
|
+
averageValue: number | string;
|
|
46
|
+
};
|
|
47
|
+
export declare type KubernetesAutoscaleMetric = {
|
|
48
|
+
type: "Resource";
|
|
49
|
+
resource: {
|
|
50
|
+
name: "cpu" | "memory";
|
|
51
|
+
target: KubernetesAutoscaleMetricResourceTarget;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export declare type KubernetesAutoscale = {
|
|
55
|
+
minReplicas: number;
|
|
56
|
+
maxReplicas: number;
|
|
57
|
+
/**
|
|
58
|
+
* declare a number of metrics (at least one). Usually you would use cpu as a metric
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
metrics: KubernetesAutoscaleMetric[];
|
|
62
|
+
};
|
|
63
|
+
declare type KubernetesHealthDef = {
|
|
64
|
+
httpGet?: {
|
|
65
|
+
path?: string;
|
|
66
|
+
port?: number;
|
|
67
|
+
httpHeaders?: {
|
|
68
|
+
name: string;
|
|
69
|
+
value: string;
|
|
70
|
+
}[];
|
|
71
|
+
failureThreshold?: number;
|
|
72
|
+
timeoutSeconds?: number;
|
|
73
|
+
periodSeconds?: number;
|
|
74
|
+
successThreshold?: number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare type DeployConfigKubernetesValues = AllowUnknownProps<{
|
|
78
|
+
/**
|
|
79
|
+
* enable cloudsql db. Currently you have to manually set it up
|
|
80
|
+
*/
|
|
81
|
+
cloudsql?: {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
instanceId?: string;
|
|
84
|
+
projectId?: string;
|
|
85
|
+
region?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* enable mongodb. The mongodb is deployed using a helm chart.
|
|
89
|
+
* Consider using external services instead of this.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
mongodb?: AllowUnknownProps<{
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* enable mailhog. Mailhog is a virtual mail server that catches all outgoing mailsl and show them in a mailbox.
|
|
97
|
+
* This is great for development as it prevents to accidentially send out real emails and helps with debugging outgoing mails.
|
|
98
|
+
*
|
|
99
|
+
* It will automaticaly inject a MAIL_URL env var.
|
|
100
|
+
*
|
|
101
|
+
* Turn it of for production.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
mailhog?: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* post-install/upgrade jobs. These use the app image and have all env vars available.
|
|
109
|
+
* Typically used for migrations and seeds
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
jobs?: Record<string, AllowUnknownProps<{
|
|
113
|
+
command: string;
|
|
114
|
+
}>>;
|
|
115
|
+
/**
|
|
116
|
+
* cronjobs that run periodically. These use the app image have all env vars available.
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
cronjobs?: Record<string, AllowUnknownProps<{
|
|
120
|
+
schedule: string;
|
|
121
|
+
command: string;
|
|
122
|
+
concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
|
|
123
|
+
}>>;
|
|
124
|
+
/**
|
|
125
|
+
* configuration for the application ("Deployment" in kubernetes)
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
application?: AllowUnknownProps<{
|
|
129
|
+
/**
|
|
130
|
+
* redirects
|
|
131
|
+
*/
|
|
132
|
+
redirects?: AllowUnknownProps<{
|
|
133
|
+
host: string;
|
|
134
|
+
}>[];
|
|
135
|
+
/**
|
|
136
|
+
* how many pods will be started
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
replicas?: number;
|
|
140
|
+
/**
|
|
141
|
+
* autoscale the pods horizontally
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
autoscale?: KubernetesAutoscale;
|
|
145
|
+
/**
|
|
146
|
+
* kubernetes resources
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
resources?: {
|
|
150
|
+
limits?: {
|
|
151
|
+
cpu?: string;
|
|
152
|
+
memory?: string;
|
|
153
|
+
};
|
|
154
|
+
requests?: {
|
|
155
|
+
cpu?: string;
|
|
156
|
+
memory?: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
healthRoute?: string;
|
|
160
|
+
startupProbe?: KubernetesHealthDef;
|
|
161
|
+
readinessProbe?: KubernetesHealthDef;
|
|
162
|
+
livenessProbe?: KubernetesHealthDef;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Mount secrets as files in the filesystem.
|
|
166
|
+
* These secrets are still available as env vars, but will contain the path of the file instead
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
secretsAsFile?: string[];
|
|
170
|
+
}>;
|
|
3
171
|
export declare type DeployConfigKubernetes = {
|
|
4
172
|
type: "kubernetes";
|
|
5
|
-
|
|
173
|
+
/**
|
|
174
|
+
* cluster config to use.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
cluster: DeployConfigKubernetesCluster;
|
|
178
|
+
/**
|
|
179
|
+
* prints out debug info (helm --debug)
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
debug?: boolean;
|
|
6
183
|
additionalHelmArgs?: string[];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
region?: string;
|
|
13
|
-
};
|
|
14
|
-
mongodb?: AllowUnknownProps<{
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
}>;
|
|
17
|
-
mailhog?: {
|
|
18
|
-
enabled: boolean;
|
|
19
|
-
};
|
|
20
|
-
jobs?: Record<string, AllowUnknownProps<{
|
|
21
|
-
command: string;
|
|
22
|
-
}>>;
|
|
23
|
-
cronjobs?: Record<string, AllowUnknownProps<{
|
|
24
|
-
schedule: string;
|
|
25
|
-
command: string;
|
|
26
|
-
concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
|
|
27
|
-
}>>;
|
|
28
|
-
application?: AllowUnknownProps<{
|
|
29
|
-
redirects?: AllowUnknownProps<{
|
|
30
|
-
host: string;
|
|
31
|
-
}>[];
|
|
32
|
-
replicas?: number;
|
|
33
|
-
resources?: {
|
|
34
|
-
limits?: {
|
|
35
|
-
cpu?: string;
|
|
36
|
-
memory?: string;
|
|
37
|
-
};
|
|
38
|
-
requests?: {
|
|
39
|
-
cpu?: string;
|
|
40
|
-
memory?: string;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
}>;
|
|
44
|
-
}>;
|
|
184
|
+
/**
|
|
185
|
+
* values to configure the app
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
values?: DeployConfigKubernetesValues;
|
|
45
189
|
} & DeployConfigBase;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
region?: string | undefined;
|
|
57
|
-
} | undefined;
|
|
58
|
-
mongodb?: AllowUnknownProps<{
|
|
59
|
-
enabled: boolean;
|
|
60
|
-
}> | undefined;
|
|
61
|
-
mailhog?: {
|
|
62
|
-
enabled: boolean;
|
|
63
|
-
} | undefined;
|
|
64
|
-
jobs?: Record<string, AllowUnknownProps<{
|
|
65
|
-
command: string;
|
|
66
|
-
}>> | undefined;
|
|
67
|
-
cronjobs?: Record<string, AllowUnknownProps<{
|
|
68
|
-
schedule: string;
|
|
69
|
-
command: string;
|
|
70
|
-
concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
|
|
71
|
-
}>> | undefined;
|
|
72
|
-
application?: AllowUnknownProps<{
|
|
73
|
-
redirects?: AllowUnknownProps<{
|
|
74
|
-
host: string;
|
|
75
|
-
}>[] | undefined;
|
|
76
|
-
replicas?: number | undefined;
|
|
77
|
-
resources?: {
|
|
78
|
-
limits?: {
|
|
79
|
-
cpu?: string | undefined;
|
|
80
|
-
memory?: string | undefined;
|
|
81
|
-
} | undefined;
|
|
82
|
-
requests?: {
|
|
83
|
-
cpu?: string | undefined;
|
|
84
|
-
memory?: string | undefined;
|
|
85
|
-
} | undefined;
|
|
86
|
-
} | undefined;
|
|
87
|
-
}> | undefined;
|
|
88
|
-
}> | undefined;
|
|
89
|
-
}, {
|
|
190
|
+
declare type DeployConfigCustom = {
|
|
191
|
+
type: "custom";
|
|
192
|
+
requiresDocker: boolean;
|
|
193
|
+
script: string[];
|
|
194
|
+
stopScript?: string[];
|
|
195
|
+
} & DeployConfigBase;
|
|
196
|
+
export declare type DeployConfig = DeployConfigKubernetes | DeployConfigCustom;
|
|
197
|
+
export declare const isOfDeployType: <T extends ("kubernetes" | "custom")[]>(t: DeployConfig | false, ...types: T) => t is Extract<DeployConfigKubernetes, {
|
|
198
|
+
type: T[number];
|
|
199
|
+
}> | Extract<DeployConfigCustom, {
|
|
90
200
|
type: T[number];
|
|
91
201
|
}>;
|
|
92
202
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Config, Context } from "../types";
|
|
2
|
+
import { DeployConfigKubernetesCluster } from "./types";
|
|
3
|
+
export declare const getFullKubernetesClusterName: (cluster: DeployConfigKubernetesCluster) => string | undefined;
|
|
4
|
+
export declare const getKubernetesNamespace: (config: Pick<Config, "customerName" | "appName">, env: string) => string;
|
|
5
|
+
export declare const contextIsStoppable: (context: Context) => boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.contextIsStoppable = exports.getKubernetesNamespace = exports.getFullKubernetesClusterName = void 0;
|
|
5
|
+
|
|
6
|
+
var types_1 = require("./types");
|
|
7
|
+
|
|
8
|
+
var getFullKubernetesClusterName = function (cluster) {
|
|
9
|
+
if (cluster.type === "gcloud") {
|
|
10
|
+
return "gke_".concat(cluster.projectId, "_").concat(cluster.region, "_").concat(cluster.name);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getFullKubernetesClusterName = getFullKubernetesClusterName;
|
|
15
|
+
|
|
16
|
+
var getKubernetesNamespace = function (config, env) {
|
|
17
|
+
return "".concat(config.customerName, "-").concat(config.appName, "-").concat(env);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.getKubernetesNamespace = getKubernetesNamespace;
|
|
21
|
+
|
|
22
|
+
var contextIsStoppable = function (context) {
|
|
23
|
+
var deployConfig = context.componentConfig.deploy;
|
|
24
|
+
|
|
25
|
+
if ((0, types_1.isOfDeployType)(deployConfig, "kubernetes")) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if ((0, types_1.isOfDeployType)(deployConfig, "custom") && deployConfig.stopScript) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.contextIsStoppable = contextIsStoppable;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
+
import { Pipeline } from "../types";
|
|
1
2
|
import { Config, PipelineTrigger } from "../types/config";
|
|
2
|
-
|
|
3
|
-
export declare const createChildPipeline: (trigger: PipelineTrigger, config: Config) => Promise<{
|
|
4
|
-
image: string;
|
|
5
|
-
workflow: {
|
|
6
|
-
rules: import("../types/gitlab-types").GitlabRule[];
|
|
7
|
-
};
|
|
8
|
-
stages: string[];
|
|
9
|
-
} & Record<string, GitlabJobDef>>;
|
|
3
|
+
export declare const createChildPipeline: <T extends "gitlab">(type: T, trigger: PipelineTrigger, config: Config) => Promise<Pipeline<T>>;
|
|
@@ -195,17 +195,17 @@ exports.createChildPipeline = void 0;
|
|
|
195
195
|
|
|
196
196
|
var config_1 = require("../config");
|
|
197
197
|
|
|
198
|
-
var createJobs_1 = require("./createJobs");
|
|
199
|
-
|
|
200
198
|
var rules_1 = require("../rules");
|
|
201
199
|
|
|
202
200
|
var runner_1 = require("../runner");
|
|
203
201
|
|
|
202
|
+
var createJobs_1 = require("./createJobs");
|
|
203
|
+
|
|
204
204
|
var baseStages = ["setup", "test", "build", "deploy", "verify", "stop"];
|
|
205
205
|
|
|
206
|
-
var createChildPipeline = function (trigger, config) {
|
|
206
|
+
var createChildPipeline = function (type, trigger, config) {
|
|
207
207
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
-
var components, jobs, allEnvs, stages,
|
|
208
|
+
var components, jobs, allEnvs, stages, pipeline;
|
|
209
209
|
return __generator(this, function (_a) {
|
|
210
210
|
switch (_a.label) {
|
|
211
211
|
case 0:
|
|
@@ -229,7 +229,7 @@ var createChildPipeline = function (trigger, config) {
|
|
|
229
229
|
_b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
|
|
230
230
|
return [4
|
|
231
231
|
/*yield*/
|
|
232
|
-
, (0, createJobs_1.createJobs)(envs, config, componentName, trigger)];
|
|
232
|
+
, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
|
|
233
233
|
|
|
234
234
|
case 2:
|
|
235
235
|
return [2
|
|
@@ -248,16 +248,25 @@ var createChildPipeline = function (trigger, config) {
|
|
|
248
248
|
return "".concat(baseStage, " ").concat(e);
|
|
249
249
|
})), false);
|
|
250
250
|
}, []);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
251
|
+
|
|
252
|
+
if (type === "gitlab") {
|
|
253
|
+
pipeline = {
|
|
254
|
+
image: (0, runner_1.getRunnerImage)("jobs-default"),
|
|
255
|
+
variables: {
|
|
256
|
+
FF_USE_FASTZIP: "true"
|
|
257
|
+
},
|
|
258
|
+
workflow: {
|
|
259
|
+
rules: rules_1.RULES_ALWAYS
|
|
260
|
+
},
|
|
261
|
+
stages: stages,
|
|
262
|
+
jobs: jobs
|
|
263
|
+
};
|
|
264
|
+
return [2
|
|
265
|
+
/*return*/
|
|
266
|
+
, pipeline];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
throw new Error("".concat(type, " is not supported"));
|
|
261
270
|
}
|
|
262
271
|
});
|
|
263
272
|
});
|
|
@@ -141,17 +141,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
var __rest = this && this.__rest || function (s, e) {
|
|
145
|
-
var t = {};
|
|
146
|
-
|
|
147
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
148
|
-
|
|
149
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
150
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
151
|
-
}
|
|
152
|
-
return t;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
144
|
exports.__esModule = true;
|
|
156
145
|
|
|
157
146
|
var createChildPipeline_1 = require("./createChildPipeline");
|
|
@@ -168,24 +157,30 @@ describe("createChildPipeline", function () {
|
|
|
168
157
|
type: "node"
|
|
169
158
|
},
|
|
170
159
|
deploy: {
|
|
171
|
-
type: "kubernetes"
|
|
160
|
+
type: "kubernetes",
|
|
161
|
+
cluster: {
|
|
162
|
+
type: "gcloud",
|
|
163
|
+
name: "mega-cluster",
|
|
164
|
+
projectId: "super-google-project",
|
|
165
|
+
region: "ch-blabla"
|
|
166
|
+
}
|
|
172
167
|
}
|
|
173
168
|
}
|
|
174
169
|
}
|
|
175
170
|
};
|
|
176
171
|
it("creates a pipeline for a single app on the main branch", function () {
|
|
177
172
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
-
var _a, image,
|
|
173
|
+
var _a, image, jobs;
|
|
179
174
|
|
|
180
175
|
return __generator(this, function (_b) {
|
|
181
176
|
switch (_b.label) {
|
|
182
177
|
case 0:
|
|
183
178
|
return [4
|
|
184
179
|
/*yield*/
|
|
185
|
-
, (0, createChildPipeline_1.createChildPipeline)("mainBranch", config)];
|
|
180
|
+
, (0, createChildPipeline_1.createChildPipeline)("gitlab", "mainBranch", config)];
|
|
186
181
|
|
|
187
182
|
case 1:
|
|
188
|
-
_a = _b.sent(), image = _a.image,
|
|
183
|
+
_a = _b.sent(), image = _a.image, jobs = _a.jobs;
|
|
189
184
|
expect(image).toEqual("git.panter.ch:5001/catladder/catladder/base-pipeline:");
|
|
190
185
|
expect(Object.keys(jobs)).toEqual(["my-app audit", "my-app lint", "my-app test", "dev my-app app-build", "dev my-app docker-build", "dev my-app deploy-to-kubernetes", "dev my-app kubernetes-stop"]);
|
|
191
186
|
return [2
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { PipelineJob } from "../types";
|
|
1
2
|
import { Config, PipelineTrigger } from "../types/config";
|
|
2
|
-
|
|
3
|
-
export declare const createJobs: (envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, GitlabJobDef>>;
|
|
3
|
+
export declare const createJobs: <T extends "gitlab">(type: T, envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, PipelineJob<T>>>;
|