@catladder/pipeline 0.0.0-kube-command-59ed84cc → 0.0.0-kubernetes-new-cloudsql-d0cdae5b
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/docker.d.ts +4 -18
- package/dist/build/docker.js +15 -9
- package/dist/build/rails/build.js +4 -8
- package/dist/build/rails/test.js +1 -2
- package/dist/bundles/catladder-gitlab/index.js +476 -197
- package/dist/constants.js +1 -1
- package/dist/deploy/cloudRun/index.js +5 -4
- package/dist/deploy/cloudSql/utils.d.ts +3 -0
- package/dist/deploy/cloudSql/utils.js +9 -0
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +10 -10
- package/dist/deploy/kubernetes/cloudSql/index.js +36 -15
- package/dist/deploy/kubernetes/kubeValues.d.ts +1 -6
- package/dist/deploy/kubernetes/kubeValues.js +1 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -6
- package/dist/deploy/types/kubernetes.d.ts +43 -6
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/pipeline/createAllJobs.js +164 -0
- package/dist/pipeline/createChildPipeline.js +24 -48
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -100
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -20
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -20
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -20
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -40
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +16 -40
- package/examples/__snapshots__/custom-build-job.ts.snap +8 -20
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +2240 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +2252 -0
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +48 -12
- package/examples/kubernetes-with-cloud-sql-legacy.ts +33 -0
- package/examples/kubernetes-with-cloud-sql.ts +35 -0
- package/package.json +1 -1
- package/src/build/docker.ts +13 -6
- package/src/build/index.ts +1 -1
- package/src/build/node/cache.ts +2 -2
- package/src/build/rails/build.ts +9 -6
- package/src/build/rails/test.ts +43 -39
- package/src/config/configruedEnvs.ts +2 -8
- package/src/deploy/cloudRun/index.ts +7 -8
- package/src/deploy/cloudSql/utils.ts +23 -0
- package/src/deploy/kubernetes/cloudSql/index.ts +58 -14
- package/src/deploy/kubernetes/deployJob.ts +2 -1
- package/src/deploy/kubernetes/kubeValues.ts +7 -2
- package/src/deploy/types/kubernetes.ts +48 -6
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +6 -22
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/types/gitlab-types.ts +8 -6
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -75
- package/src/pipeline/createJobs.ts +0 -196
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -25
package/dist/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
5
|
-
exports.PIPELINE_IMAGE_TAG = "
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "kubernetes-new-cloudsql-d0cdae5b" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
@@ -45,20 +45,21 @@ exports.__esModule = true;
|
|
|
45
45
|
exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
|
|
46
46
|
var context_1 = require("../../context");
|
|
47
47
|
var gitlab_1 = require("../../utils/gitlab");
|
|
48
|
+
var utils_1 = require("../cloudSql/utils");
|
|
48
49
|
var deployJob_1 = require("./deployJob");
|
|
49
50
|
var jobName_1 = require("./utils/jobName");
|
|
50
51
|
exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
51
52
|
exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
|
|
52
53
|
var getCloudSqlVariables = function (_a) {
|
|
53
|
-
var _b, _c
|
|
54
|
+
var _b, _c;
|
|
54
55
|
var deployConfigRaw = _a.deployConfigRaw,
|
|
55
56
|
environmentSlugPrefix = _a.environmentSlugPrefix,
|
|
56
57
|
env = _a.env,
|
|
57
58
|
componentName = _a.componentName,
|
|
58
59
|
fullConfig = _a.fullConfig;
|
|
59
60
|
if (deployConfigRaw && deployConfigRaw.cloudSql) {
|
|
60
|
-
var DB_NAME =
|
|
61
|
-
var additionalQueryParamsString = Object.entries((
|
|
61
|
+
var DB_NAME = (0, utils_1.getFullDbName)(deployConfigRaw.cloudSql, fullConfig, environmentSlugPrefix, componentName);
|
|
62
|
+
var additionalQueryParamsString = Object.entries((_b = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
62
63
|
var _b = __read(_a, 2),
|
|
63
64
|
key = _b[0],
|
|
64
65
|
value = _b[1];
|
|
@@ -67,7 +68,7 @@ var getCloudSqlVariables = function (_a) {
|
|
|
67
68
|
return {
|
|
68
69
|
CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
|
|
69
70
|
DB_NAME: DB_NAME,
|
|
70
|
-
DB_USER: (
|
|
71
|
+
DB_USER: (_c = deployConfigRaw.cloudSql.dbUser) !== null && _c !== void 0 ? _c : "postgres",
|
|
71
72
|
DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
|
|
72
73
|
DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
|
|
73
74
|
DATABASE_JDBC_URL: "jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD".concat(additionalQueryParamsString)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Config } from "../..";
|
|
2
|
+
import type { DeployConfigCloudRunCloudSql, DeployConfigKubernetesValuesCloudSQLUnmanaged } from "../types";
|
|
3
|
+
export declare const getFullDbName: (cloudSqlConfig: DeployConfigCloudRunCloudSql | DeployConfigKubernetesValuesCloudSQLUnmanaged, fullConfig: Config<never>, environmentSlugPrefix: string, componentName: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getFullDbName = void 0;
|
|
5
|
+
var getFullDbName = function (cloudSqlConfig, fullConfig, environmentSlugPrefix, componentName) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
return [(_a = cloudSqlConfig.dbNamePrefix) !== null && _a !== void 0 ? _a : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlugPrefix, (_b = cloudSqlConfig.dbBaseName) !== null && _b !== void 0 ? _b : componentName].filter(Boolean).join("-");
|
|
8
|
+
};
|
|
9
|
+
exports.getFullDbName = getFullDbName;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Context } from "../../../types";
|
|
2
2
|
export declare const hasKubernetesCloudSQL: (context: Context) => boolean | undefined;
|
|
3
|
-
|
|
3
|
+
declare type CloudSqlValues = {
|
|
4
4
|
enabled: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
5
|
+
proxyCredentials: string;
|
|
6
|
+
instanceConnectionName: string;
|
|
7
|
+
fullDbName: string;
|
|
8
|
+
dbUser: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const createKubernetesCloudsqlBaseValues: (context: Context) => {
|
|
11
|
+
cloudsql: CloudSqlValues;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
4
|
+
exports.createKubernetesCloudsqlBaseValues = exports.hasKubernetesCloudSQL = void 0;
|
|
5
5
|
var context_1 = require("../../../context");
|
|
6
|
+
var utils_1 = require("../../cloudSql/utils");
|
|
6
7
|
var types_1 = require("../../types");
|
|
7
8
|
var hasKubernetesCloudSQL = function (context) {
|
|
8
9
|
var _a, _b;
|
|
@@ -12,19 +13,39 @@ var hasKubernetesCloudSQL = function (context) {
|
|
|
12
13
|
return false;
|
|
13
14
|
};
|
|
14
15
|
exports.hasKubernetesCloudSQL = hasKubernetesCloudSQL;
|
|
15
|
-
var
|
|
16
|
-
var _a;
|
|
17
|
-
if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
|
|
18
|
-
|
|
16
|
+
var createKubernetesCloudsqlBaseValues = function (context) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
if (!(0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
|
|
19
|
+
throw new Error("cannot get cloud sql config");
|
|
20
|
+
}
|
|
21
|
+
var config = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql;
|
|
22
|
+
if (!config) {
|
|
23
|
+
throw new Error("cannot get cloud sql config");
|
|
24
|
+
}
|
|
25
|
+
var proxyCredentials = "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"));
|
|
26
|
+
if ((config === null || config === void 0 ? void 0 : config.type) !== "unmanaged") {
|
|
27
|
+
var instanceConnectionName = "".concat((_b = config.projectId) !== null && _b !== void 0 ? _b : "skynet-164509", ":").concat((_c = config.region) !== null && _c !== void 0 ? _c : "europe-west6", ":").concat((_d = config.instanceId) !== null && _d !== void 0 ? _d : context.environment.envVars.KUBE_NAMESPACE);
|
|
28
|
+
return {
|
|
29
|
+
cloudsql: {
|
|
30
|
+
enabled: config.enabled,
|
|
31
|
+
dbUser: "postgres",
|
|
32
|
+
instanceConnectionName: instanceConnectionName,
|
|
33
|
+
proxyCredentials: proxyCredentials,
|
|
34
|
+
fullDbName: context.environment.envVars.KUBE_APP_NAME
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
} else if (config.type === "unmanaged") {
|
|
38
|
+
return {
|
|
39
|
+
cloudsql: {
|
|
40
|
+
enabled: config.enabled,
|
|
41
|
+
dbUser: (_e = config.dbUser) !== null && _e !== void 0 ? _e : "postgres",
|
|
42
|
+
instanceConnectionName: config.instanceConnectionName,
|
|
43
|
+
proxyCredentials: proxyCredentials,
|
|
44
|
+
fullDbName: (0, utils_1.getFullDbName)(config, context.fullConfig, context.environment.slugPrefix, context.componentName)
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
throw new Error("unknonw type");
|
|
19
49
|
}
|
|
20
|
-
throw new Error("cannot get cloud sql config");
|
|
21
|
-
};
|
|
22
|
-
exports.getKubernetesCloudSQLConfig = getKubernetesCloudSQLConfig;
|
|
23
|
-
var createCloudsqlBaseConfig = function (context) {
|
|
24
|
-
return {
|
|
25
|
-
cloudsql: {
|
|
26
|
-
proxyCredentials: "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"))
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
50
|
};
|
|
30
|
-
exports.
|
|
51
|
+
exports.createKubernetesCloudsqlBaseValues = createKubernetesCloudsqlBaseValues;
|
|
@@ -64,12 +64,7 @@ export declare const createKubeValues: (context: Context) => never[] | ({
|
|
|
64
64
|
} | undefined;
|
|
65
65
|
}> | undefined;
|
|
66
66
|
} & {
|
|
67
|
-
cloudsql?:
|
|
68
|
-
enabled: boolean;
|
|
69
|
-
instanceId?: string | undefined;
|
|
70
|
-
projectId?: string | undefined;
|
|
71
|
-
region?: string | undefined;
|
|
72
|
-
} | undefined;
|
|
67
|
+
cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQL | undefined;
|
|
73
68
|
mongodb?: import("../types").DeployConfigMongodb | undefined;
|
|
74
69
|
mailhog?: {
|
|
75
70
|
enabled: boolean;
|
|
@@ -114,7 +114,7 @@ var createKubeValues = function (context) {
|
|
|
114
114
|
var defaultKubeValues = (0, lodash_1.merge)({
|
|
115
115
|
env: env,
|
|
116
116
|
application: createAppConfig(context, application)
|
|
117
|
-
}, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.
|
|
117
|
+
}, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.createKubernetesCloudsqlBaseValues)(context) : {}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
|
|
118
118
|
var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
|
|
119
119
|
jobs: removeFalsy(jobs),
|
|
120
120
|
cronjobs: removeFalsy(cronjobs)
|
|
@@ -3,12 +3,7 @@ export declare const processSecretsAsFiles: <T extends {
|
|
|
3
3
|
secret: Record<string, string>;
|
|
4
4
|
};
|
|
5
5
|
} & {
|
|
6
|
-
cloudsql?:
|
|
7
|
-
enabled: boolean;
|
|
8
|
-
instanceId?: string | undefined;
|
|
9
|
-
projectId?: string | undefined;
|
|
10
|
-
region?: string | undefined;
|
|
11
|
-
} | undefined;
|
|
6
|
+
cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQL | undefined;
|
|
12
7
|
mongodb?: import("../types").DeployConfigMongodb | undefined;
|
|
13
8
|
mailhog?: {
|
|
14
9
|
enabled: boolean;
|
|
@@ -119,16 +119,53 @@ export declare type DeployConfigMongodbReplicaset = {
|
|
|
119
119
|
replicaCount?: number;
|
|
120
120
|
};
|
|
121
121
|
export declare type DeployConfigMongodb = DeployConfigMongodbBase & (DeployConfigMongodbStandalone | DeployConfigMongodbReplicaset);
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated use config with instanceConnectionName
|
|
124
|
+
*/
|
|
125
|
+
declare type DeployConfigKubernetesValuesCloudSQLLegacy = {
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated use config with instanceConnectionName
|
|
129
|
+
*/
|
|
130
|
+
instanceId?: string;
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated use config with instanceConnectionName
|
|
133
|
+
*/
|
|
134
|
+
projectId?: string;
|
|
135
|
+
/**
|
|
136
|
+
* @deprecated use config with instanceConnectionName
|
|
137
|
+
*/
|
|
138
|
+
region?: string;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated use type "current"
|
|
141
|
+
*/
|
|
142
|
+
type?: "legacy";
|
|
143
|
+
};
|
|
144
|
+
export declare type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
instanceConnectionName: string;
|
|
147
|
+
type: "unmanaged";
|
|
148
|
+
/**
|
|
149
|
+
* the database username, defaults to "postgres"
|
|
150
|
+
*/
|
|
151
|
+
dbUser?: string;
|
|
152
|
+
/**
|
|
153
|
+
* the prefix of the database, the full db name is this plus the environment slug prefix plus the componentName
|
|
154
|
+
*
|
|
155
|
+
* defaults to customerName-appName
|
|
156
|
+
*/
|
|
157
|
+
dbNamePrefix?: string | false;
|
|
158
|
+
/**
|
|
159
|
+
* the base name of the db, defaults to the componentName
|
|
160
|
+
*/
|
|
161
|
+
dbBaseName?: string;
|
|
162
|
+
};
|
|
163
|
+
export declare type DeployConfigKubernetesValuesCloudSQL = DeployConfigKubernetesValuesCloudSQLLegacy | DeployConfigKubernetesValuesCloudSQLUnmanaged;
|
|
122
164
|
export declare type DeployConfigKubernetesValues = AllowUnknownProps<{
|
|
123
165
|
/**
|
|
124
166
|
* enable cloudsql db. Currently you have to manually set it up
|
|
125
167
|
*/
|
|
126
|
-
cloudsql?:
|
|
127
|
-
enabled: boolean;
|
|
128
|
-
instanceId?: string;
|
|
129
|
-
projectId?: string;
|
|
130
|
-
region?: string;
|
|
131
|
-
};
|
|
168
|
+
cloudsql?: DeployConfigKubernetesValuesCloudSQL;
|
|
132
169
|
/**
|
|
133
170
|
* enable mongodb. The mongodb is deployed using a helm chart.
|
|
134
171
|
* See https://github.com/bitnami/charts/tree/master/bitnami/mongodb
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config, PipelineTrigger } from "../types";
|
|
2
|
+
import type { CatladderJob } from "../types/jobs";
|
|
3
|
+
export declare type AllCatladderJobs = {
|
|
4
|
+
[componentName: string]: {
|
|
5
|
+
[env: string]: Array<CatladderJob>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const createAllJobs: (config: Config, trigger: PipelineTrigger) => Promise<AllCatladderJobs>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
+
resolve(value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.next(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function step(result) {
|
|
25
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
+
}
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
+
var _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function () {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
},
|
|
40
|
+
f,
|
|
41
|
+
y,
|
|
42
|
+
t,
|
|
43
|
+
g;
|
|
44
|
+
return g = {
|
|
45
|
+
next: verb(0),
|
|
46
|
+
"throw": verb(1),
|
|
47
|
+
"return": verb(2)
|
|
48
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
+
return this;
|
|
50
|
+
}), g;
|
|
51
|
+
function verb(n) {
|
|
52
|
+
return function (v) {
|
|
53
|
+
return step([n, v]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while (_) try {
|
|
59
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
+
switch (op[0]) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
t = op;
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
_.label++;
|
|
68
|
+
return {
|
|
69
|
+
value: op[1],
|
|
70
|
+
done: false
|
|
71
|
+
};
|
|
72
|
+
case 5:
|
|
73
|
+
_.label++;
|
|
74
|
+
y = op[1];
|
|
75
|
+
op = [0];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [6, e];
|
|
107
|
+
y = 0;
|
|
108
|
+
} finally {
|
|
109
|
+
f = t = 0;
|
|
110
|
+
}
|
|
111
|
+
if (op[0] & 5) throw op[1];
|
|
112
|
+
return {
|
|
113
|
+
value: op[0] ? op[1] : void 0,
|
|
114
|
+
done: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
exports.__esModule = true;
|
|
119
|
+
exports.createAllJobs = void 0;
|
|
120
|
+
var config_1 = require("../config");
|
|
121
|
+
var createJobsForComponent_1 = require("./createJobsForComponent");
|
|
122
|
+
var createAllJobs = function (config, trigger) {
|
|
123
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
return __generator(this, function (_c) {
|
|
126
|
+
switch (_c.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
_b = (_a = Object).fromEntries;
|
|
129
|
+
return [4 /*yield*/, Promise.all(Object.keys(config.components).map(function (componentName) {
|
|
130
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
131
|
+
var envs, _a, _b, _c;
|
|
132
|
+
return __generator(this, function (_d) {
|
|
133
|
+
switch (_d.label) {
|
|
134
|
+
case 0:
|
|
135
|
+
envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
|
|
136
|
+
_a = [componentName];
|
|
137
|
+
_c = (_b = Object).fromEntries;
|
|
138
|
+
return [4 /*yield*/, Promise.all(envs.map(function (env) {
|
|
139
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var _a;
|
|
141
|
+
return __generator(this, function (_b) {
|
|
142
|
+
switch (_b.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
_a = [env];
|
|
145
|
+
return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponent)(config, componentName, env, trigger)];
|
|
146
|
+
case 1:
|
|
147
|
+
return [2 /*return*/, _a.concat([_b.sent()])];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}))];
|
|
152
|
+
case 1:
|
|
153
|
+
return [2 /*return*/, _a.concat([_c.apply(_b, [_d.sent()])])];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}))];
|
|
158
|
+
case 1:
|
|
159
|
+
return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
exports.createAllJobs = createAllJobs;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
3
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
14
4
|
function adopt(value) {
|
|
15
5
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -162,54 +152,40 @@ var config_1 = require("../config");
|
|
|
162
152
|
var rules_1 = require("../rules");
|
|
163
153
|
var runner_1 = require("../runner");
|
|
164
154
|
var jobs_1 = require("../types/jobs");
|
|
165
|
-
var
|
|
155
|
+
var createAllJobs_1 = require("./createAllJobs");
|
|
156
|
+
var createGitlabJobs_1 = require("./gitlab/createGitlabJobs");
|
|
166
157
|
var createChildPipeline = function (type, trigger, config) {
|
|
167
158
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
var jobs, allEnvs, stages, pipeline;
|
|
160
|
+
var _a;
|
|
161
|
+
return __generator(this, function (_b) {
|
|
162
|
+
switch (_b.label) {
|
|
171
163
|
case 0:
|
|
172
|
-
|
|
173
|
-
return [4 /*yield*/, components.reduce(function (acc, componentName) {
|
|
174
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
175
|
-
var envs, _a, _b;
|
|
176
|
-
return __generator(this, function (_c) {
|
|
177
|
-
switch (_c.label) {
|
|
178
|
-
case 0:
|
|
179
|
-
envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
|
|
180
|
-
_a = [{}];
|
|
181
|
-
return [4 /*yield*/, acc];
|
|
182
|
-
case 1:
|
|
183
|
-
_b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
|
|
184
|
-
return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
|
|
185
|
-
case 2:
|
|
186
|
-
return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
}, Promise.resolve({}))];
|
|
164
|
+
return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
|
|
191
165
|
case 1:
|
|
192
|
-
jobs =
|
|
166
|
+
jobs = _b.sent();
|
|
193
167
|
allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
|
|
194
168
|
stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
|
|
195
169
|
return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
|
|
196
170
|
return "".concat(baseStage, " ").concat(e);
|
|
197
171
|
})), false);
|
|
198
172
|
}, []);
|
|
199
|
-
if (type === "gitlab")
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
173
|
+
if (!(type === "gitlab")) return [3 /*break*/, 3];
|
|
174
|
+
_a = {
|
|
175
|
+
image: (0, runner_1.getRunnerImage)("jobs-default"),
|
|
176
|
+
variables: {
|
|
177
|
+
FF_USE_FASTZIP: "true"
|
|
178
|
+
},
|
|
179
|
+
workflow: {
|
|
180
|
+
rules: rules_1.RULES_ALWAYS
|
|
181
|
+
},
|
|
182
|
+
stages: stages
|
|
183
|
+
};
|
|
184
|
+
return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
|
|
185
|
+
case 2:
|
|
186
|
+
pipeline = (_a.jobs = _b.sent(), _a);
|
|
187
|
+
return [2 /*return*/, pipeline];
|
|
188
|
+
case 3:
|
|
213
189
|
throw new Error("".concat(type, " is not supported"));
|
|
214
190
|
}
|
|
215
191
|
});
|
|
@@ -165,14 +165,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
165
165
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
166
166
|
};
|
|
167
167
|
exports.__esModule = true;
|
|
168
|
-
exports.
|
|
168
|
+
exports.createJobsForComponent = void 0;
|
|
169
169
|
var lodash_1 = require("lodash");
|
|
170
170
|
var build_1 = require("../build");
|
|
171
171
|
var context_1 = require("../context");
|
|
172
172
|
var deploy_1 = require("../deploy");
|
|
173
|
-
var utils_1 = require("../utils");
|
|
174
173
|
var getCommitInfo_1 = require("./commitInfo/getCommitInfo");
|
|
175
|
-
var makeGitlabJob_1 = require("./gitlab/makeGitlabJob");
|
|
176
174
|
var packageManager_1 = require("./packageManager");
|
|
177
175
|
var injectDefaultVarsInCustomJobs = function (context, jobs) {
|
|
178
176
|
return jobs.map(function (_a) {
|
|
@@ -200,71 +198,9 @@ var createRawJobs = function (context) {
|
|
|
200
198
|
var customJobs = getCustomJobs(context);
|
|
201
199
|
return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
|
|
202
200
|
};
|
|
203
|
-
var
|
|
204
|
-
if (env) {
|
|
205
|
-
return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
|
|
206
|
-
}
|
|
207
|
-
return "".concat(componentName, " ").concat(name);
|
|
208
|
-
};
|
|
209
|
-
var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
|
|
210
|
-
var referencedJob = allRawJobs.find(function (j) {
|
|
211
|
-
return j.name === referencedJobName;
|
|
212
|
-
});
|
|
213
|
-
if (!referencedJob) {
|
|
214
|
-
throw new Error("unknown job referenced: " + referencedJobName);
|
|
215
|
-
}
|
|
216
|
-
var envToSet = referencedJob.envMode !== "none" ? env : null;
|
|
217
|
-
return getFullJobName(referencedJobName, componentName, envToSet);
|
|
218
|
-
};
|
|
219
|
-
// replaces references to other jobs with the full name
|
|
220
|
-
// the full name contains the componentname and the env name (if any)
|
|
221
|
-
var replaceReferences = function (job, componentName, env, allRawJobs) {
|
|
222
|
-
var _a, _b, _c;
|
|
223
|
-
var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
|
|
224
|
-
var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
|
|
225
|
-
var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
226
|
-
var _a;
|
|
227
|
-
return (0, lodash_1.isObject)(n) ? {
|
|
228
|
-
job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
|
|
229
|
-
artifacts: n.artifacts
|
|
230
|
-
} : getFullReferencedJobName(n, componentName, env, allRawJobs);
|
|
231
|
-
});
|
|
232
|
-
return __assign(__assign({}, job), {
|
|
233
|
-
stage: stage,
|
|
234
|
-
needs: needs,
|
|
235
|
-
environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
|
|
236
|
-
on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
|
|
237
|
-
}) : job.environment
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
// this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
|
|
241
|
-
var addStageNeeds = function (jobs) {
|
|
242
|
-
// when a job defines needsStages, we add these as needs
|
|
243
|
-
return jobs.map(function (job) {
|
|
244
|
-
var _a;
|
|
245
|
-
if (!job.needsStages || job.needsStages.length === 0) {
|
|
246
|
-
return job;
|
|
247
|
-
}
|
|
248
|
-
var neededJobs = jobs.map(function (j) {
|
|
249
|
-
var _a, _b;
|
|
250
|
-
var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
|
|
251
|
-
return j.stage === s.stage;
|
|
252
|
-
});
|
|
253
|
-
if (neededStage) {
|
|
254
|
-
return {
|
|
255
|
-
job: j.name,
|
|
256
|
-
artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
}).filter(utils_1.notNil);
|
|
260
|
-
return __assign(__assign({}, job), {
|
|
261
|
-
needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
var createJobs = function (type, envs, config, componentName, trigger) {
|
|
201
|
+
var createJobsForComponent = function (config, componentName, env, trigger) {
|
|
266
202
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
267
|
-
var commitInfo, _a, packageManagerInfo;
|
|
203
|
+
var commitInfo, _a, packageManagerInfo, context;
|
|
268
204
|
return __generator(this, function (_b) {
|
|
269
205
|
switch (_b.label) {
|
|
270
206
|
case 0:
|
|
@@ -277,40 +213,12 @@ var createJobs = function (type, envs, config, componentName, trigger) {
|
|
|
277
213
|
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
|
|
278
214
|
case 2:
|
|
279
215
|
packageManagerInfo = _b.sent();
|
|
280
|
-
return [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
switch (_f.label) {
|
|
285
|
-
case 0:
|
|
286
|
-
return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
|
|
287
|
-
case 1:
|
|
288
|
-
context = _f.sent();
|
|
289
|
-
jobs = addStageNeeds(createRawJobs(context));
|
|
290
|
-
_a = [{}];
|
|
291
|
-
return [4 /*yield*/, acc];
|
|
292
|
-
case 2:
|
|
293
|
-
_b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
|
|
294
|
-
_d = (_c = jobs).reduce;
|
|
295
|
-
_e = [function (acc, job) {
|
|
296
|
-
var _a;
|
|
297
|
-
var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
|
|
298
|
-
var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
|
|
299
|
-
if (type === "gitlab") {
|
|
300
|
-
return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
|
|
301
|
-
}
|
|
302
|
-
throw new Error("not supported");
|
|
303
|
-
}];
|
|
304
|
-
return [4 /*yield*/, Promise.resolve({})];
|
|
305
|
-
case 3:
|
|
306
|
-
result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
|
|
307
|
-
return [2 /*return*/, result];
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
}, {})];
|
|
216
|
+
return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
|
|
217
|
+
case 3:
|
|
218
|
+
context = _b.sent();
|
|
219
|
+
return [2 /*return*/, createRawJobs(context)];
|
|
312
220
|
}
|
|
313
221
|
});
|
|
314
222
|
});
|
|
315
223
|
};
|
|
316
|
-
exports.
|
|
224
|
+
exports.createJobsForComponent = createJobsForComponent;
|