@catladder/pipeline 1.1.2 → 1.3.2
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/createBuildJob.js +6 -2
- package/dist/build/base/getBuildInfo.d.ts +2 -0
- package/dist/build/base/getBuildInfo.js +12 -0
- package/dist/build/docker.js +2 -1
- package/dist/build/node/meteor.js +3 -0
- package/dist/build/tests/storybook.test.js +7 -1
- package/dist/build/types.d.ts +7 -0
- package/dist/config/configruedEnvs.test.js +12 -3
- package/dist/constants.js +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.js +19 -10
- package/dist/deploy/index.d.ts +3 -1
- package/dist/deploy/index.js +4 -0
- package/dist/deploy/kubernetes/cloudsql.js +1 -1
- package/dist/deploy/kubernetes/deployJob.js +25 -8
- package/dist/deploy/types.d.ts +134 -2
- package/dist/deploy/utils.d.ts +4 -0
- package/dist/deploy/utils.js +18 -0
- package/dist/pipeline/createChildPipeline.d.ts +3 -0
- package/dist/pipeline/createChildPipeline.js +4 -1
- package/dist/pipeline/createChildPipeline.test.js +7 -1
- package/dist/pipeline/createJobs.js +21 -9
- package/dist/runner/index.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +64 -0
- package/dist/types/context.d.ts +2 -0
- package/package.json +1 -1
- package/src/build/base/createBuildJob.ts +4 -7
- package/src/build/base/getBuildInfo.ts +7 -0
- package/src/build/docker.ts +3 -2
- package/src/build/node/meteor.ts +2 -0
- package/src/build/tests/storybook.test.ts +6 -0
- package/src/build/types.ts +6 -0
- package/src/config/configruedEnvs.test.ts +10 -3
- package/src/context/index.ts +13 -4
- package/src/deploy/index.ts +3 -2
- package/src/deploy/kubernetes/cloudsql.ts +3 -4
- package/src/deploy/kubernetes/deployJob.ts +26 -5
- package/src/deploy/types.ts +66 -1
- package/src/deploy/utils.ts +17 -0
- package/src/pipeline/createChildPipeline.test.ts +6 -0
- package/src/pipeline/createChildPipeline.ts +4 -1
- package/src/pipeline/createJobs.ts +5 -0
- package/src/runner/index.ts +3 -1
- package/src/types/config.ts +56 -0
- package/src/types/context.ts +2 -0
|
@@ -65,30 +65,34 @@ exports.createBuildJob = void 0;
|
|
|
65
65
|
|
|
66
66
|
var lodash_1 = require("lodash");
|
|
67
67
|
|
|
68
|
+
var __1 = require("../..");
|
|
69
|
+
|
|
68
70
|
var defaults_1 = require("../../defaults");
|
|
69
71
|
|
|
70
72
|
var utils_1 = require("../../utils");
|
|
71
73
|
|
|
72
74
|
var constants_1 = require("./constants");
|
|
73
75
|
|
|
76
|
+
var getBuildInfo_1 = require("./getBuildInfo");
|
|
77
|
+
|
|
74
78
|
var createBuildJob = function (context, _a) {
|
|
75
79
|
var _b, _c;
|
|
76
80
|
|
|
77
81
|
var script = _a.script,
|
|
78
82
|
def = __rest(_a, ["script"]);
|
|
79
83
|
|
|
80
|
-
var buildInfo = [". getCommitInfo", "echo '{\"id\":\"'$BUILD_ID'\",\"commit\":\"'$BUILD_COMMIT'\",\"tag\":\"'$BUILD_TAG'\",\"time\":\"'$BUILD_TIME'\"}' > ".concat(context.componentConfig.dir, "/__build_info.json")];
|
|
81
84
|
return {
|
|
82
85
|
name: constants_1.APP_BUILD_JOB_NAME,
|
|
83
86
|
envMode: "jobPerEnv",
|
|
84
87
|
job: (0, lodash_1.merge)({
|
|
88
|
+
image: (0, __1.getRunnerImage)("jobs-default"),
|
|
85
89
|
needs: [],
|
|
86
90
|
cache: [],
|
|
87
91
|
variables: __assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
|
|
88
92
|
retry: defaults_1.BASE_RETRY,
|
|
89
93
|
interruptible: true,
|
|
90
94
|
stage: "build",
|
|
91
|
-
script: __spreadArray(__spreadArray(__spreadArray([], __read(
|
|
95
|
+
script: __spreadArray(__spreadArray(__spreadArray([], __read((0, getBuildInfo_1.getBuildInfo)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
|
|
92
96
|
artifacts: {
|
|
93
97
|
paths: [context.componentConfig.dir + "/__build_info.json"]
|
|
94
98
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getBuildInfo = void 0;
|
|
5
|
+
|
|
6
|
+
var getBuildInfo = function (context) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
|
|
9
|
+
return ["echo '{\"id\":\"".concat((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.buildId, "\",\"time\":\"").concat((_b = context.commitInfo) === null || _b === void 0 ? void 0 : _b.buildTime, "\"}' > ").concat(context.componentConfig.dir, "/__build_info.json")];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.getBuildInfo = getBuildInfo;
|
package/dist/build/docker.js
CHANGED
|
@@ -75,6 +75,7 @@ var createDockerBuildJob = function (context, _a) {
|
|
|
75
75
|
command: ["--tls=false"]
|
|
76
76
|
}],
|
|
77
77
|
variables: __assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
|
|
78
|
+
DOCKER_BUILDKIT: "1",
|
|
78
79
|
DOCKERFILE_ADDITIONS: (_c = (_b = context.componentConfig.build.docker) === null || _b === void 0 ? void 0 : _b.additionsBegin) === null || _c === void 0 ? void 0 : _c.join("\n"),
|
|
79
80
|
DOCKERFILE_ADDITIONS_END: (_e = (_d = context.componentConfig.build.docker) === null || _d === void 0 ? void 0 : _d.additionsEnd) === null || _e === void 0 ? void 0 : _e.join("\n"),
|
|
80
81
|
APP_DIR: context.componentConfig.dir,
|
|
@@ -88,7 +89,7 @@ var createDockerBuildJob = function (context, _a) {
|
|
|
88
89
|
})
|
|
89
90
|
};
|
|
90
91
|
return __assign(__assign({}, base), {
|
|
91
|
-
script: __spreadArray(__spreadArray([], __read(script), false), ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY", "docker
|
|
92
|
+
script: __spreadArray(__spreadArray([], __read(script), false), ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY", "docker build --network host --cache-from $CACHE_IMAGE --tag $IMAGE_NAME:$IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", "docker push $IMAGE_NAME:$IMAGE_TAG", "docker tag $IMAGE_NAME:$IMAGE_TAG $CACHE_IMAGE", "docker push $CACHE_IMAGE"], false)
|
|
92
93
|
});
|
|
93
94
|
};
|
|
94
95
|
|
|
@@ -54,6 +54,8 @@ exports.createMeteorBuildJobs = void 0;
|
|
|
54
54
|
|
|
55
55
|
var path_1 = require("path");
|
|
56
56
|
|
|
57
|
+
var runner_1 = require("../../runner");
|
|
58
|
+
|
|
57
59
|
var constants_1 = require("../base/constants");
|
|
58
60
|
|
|
59
61
|
var createBuildJob_1 = require("../base/createBuildJob");
|
|
@@ -84,6 +86,7 @@ var createMeteorBuildJobs = function (context) {
|
|
|
84
86
|
var yarnInstall = (0, yarn_1.getYarnInstall)(context);
|
|
85
87
|
var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
|
|
86
88
|
cache: __spreadArray(__spreadArray([], __read((0, cache_1.getNodeCache)(context)), false), __read(getMeteorCache(context)), false),
|
|
89
|
+
image: (0, runner_1.getRunnerImage)("jobs-meteor"),
|
|
87
90
|
script: __spreadArray(__spreadArray([], __read(yarnInstall), false), ['echo "add healthcheck package"', "meteor add panter:healthroute --allow-superuser", "meteor add qualia:prod-shell --allow-superuser", 'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory', "cp ./__build_info.json ./dist/bundle/programs/server"], false),
|
|
88
91
|
artifacts: {
|
|
89
92
|
paths: [context.componentConfig.dir + "/__build_info.json", context.componentConfig.dir + "/dist"]
|
|
@@ -168,7 +168,13 @@ describe("storybook build", function () {
|
|
|
168
168
|
type: "storybook"
|
|
169
169
|
},
|
|
170
170
|
deploy: {
|
|
171
|
-
type: "kubernetes"
|
|
171
|
+
type: "kubernetes",
|
|
172
|
+
cluster: {
|
|
173
|
+
name: "production",
|
|
174
|
+
projectId: "bla",
|
|
175
|
+
region: "europe",
|
|
176
|
+
type: "gcloud"
|
|
177
|
+
}
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
180
|
}
|
package/dist/build/types.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export declare type BuildConfigBase = {
|
|
2
|
+
/**
|
|
3
|
+
* command to run on the image to start the app (e.g. yarn start)
|
|
4
|
+
*/
|
|
2
5
|
startCommand?: string;
|
|
6
|
+
/**
|
|
7
|
+
* additional env vars for the buid jobs
|
|
8
|
+
*/
|
|
9
|
+
|
|
3
10
|
extraVars?: Record<string, string>;
|
|
4
11
|
/**
|
|
5
12
|
* define the build command
|
|
@@ -5,6 +5,12 @@ exports.__esModule = true;
|
|
|
5
5
|
var _1 = require(".");
|
|
6
6
|
|
|
7
7
|
describe("getAllEnvsByTrigger", function () {
|
|
8
|
+
var cluster = {
|
|
9
|
+
type: "gcloud",
|
|
10
|
+
name: "mega-cluster",
|
|
11
|
+
projectId: "super-google-project",
|
|
12
|
+
region: "ch-blabla"
|
|
13
|
+
};
|
|
8
14
|
var SIMPLE_CONFIG = {
|
|
9
15
|
appName: "my-app",
|
|
10
16
|
customerName: "pan",
|
|
@@ -15,7 +21,8 @@ describe("getAllEnvsByTrigger", function () {
|
|
|
15
21
|
type: "node"
|
|
16
22
|
},
|
|
17
23
|
deploy: {
|
|
18
|
-
type: "kubernetes"
|
|
24
|
+
type: "kubernetes",
|
|
25
|
+
cluster: cluster
|
|
19
26
|
}
|
|
20
27
|
},
|
|
21
28
|
app2: {
|
|
@@ -24,7 +31,8 @@ describe("getAllEnvsByTrigger", function () {
|
|
|
24
31
|
type: "node"
|
|
25
32
|
},
|
|
26
33
|
deploy: {
|
|
27
|
-
type: "kubernetes"
|
|
34
|
+
type: "kubernetes",
|
|
35
|
+
cluster: cluster
|
|
28
36
|
},
|
|
29
37
|
env: {
|
|
30
38
|
dev2: {
|
|
@@ -47,7 +55,8 @@ describe("getAllEnvsByTrigger", function () {
|
|
|
47
55
|
type: "node"
|
|
48
56
|
},
|
|
49
57
|
deploy: {
|
|
50
|
-
type: "kubernetes"
|
|
58
|
+
type: "kubernetes",
|
|
59
|
+
cluster: cluster
|
|
51
60
|
},
|
|
52
61
|
env: {
|
|
53
62
|
dev: false,
|
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 = "v1-
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "v1-3-2-d873891a" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config } from "../types/config";
|
|
2
2
|
import { CommitInfo, Context, Environment, YarnInfo } from "../types/context";
|
|
3
3
|
export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
|
|
4
|
+
export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
|
|
4
5
|
export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, skipReferences?: boolean) => Environment;
|
|
5
6
|
export declare const createContext: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, yarnInfo?: YarnInfo | undefined) => Context;
|
package/dist/context/index.js
CHANGED
|
@@ -46,7 +46,7 @@ var __importDefault = this && this.__importDefault || function (mod) {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
exports.__esModule = true;
|
|
49
|
-
exports.createContext = exports.getEnvironment = exports.getSecretVarName = void 0;
|
|
49
|
+
exports.createContext = exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
|
|
50
50
|
|
|
51
51
|
var lodash_1 = require("lodash");
|
|
52
52
|
|
|
@@ -69,9 +69,15 @@ var getSecretVarName = function (env, componentName, key) {
|
|
|
69
69
|
|
|
70
70
|
exports.getSecretVarName = getSecretVarName;
|
|
71
71
|
|
|
72
|
+
var getSecretVarNameForContext = function (context, key) {
|
|
73
|
+
return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
|
77
|
+
|
|
72
78
|
var getEnvironment = function (config, componentName, env, commitInfo, skipReferences // to prevent infinit loop
|
|
73
79
|
) {
|
|
74
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
80
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
75
81
|
|
|
76
82
|
if (skipReferences === void 0) {
|
|
77
83
|
skipReferences = false;
|
|
@@ -118,14 +124,17 @@ var getEnvironment = function (config, componentName, env, commitInfo, skipRefer
|
|
|
118
124
|
PORT: port.toString()
|
|
119
125
|
};
|
|
120
126
|
} else {
|
|
121
|
-
var KUBE_NAMESPACE = "".concat(config.customerName, "-").concat(config.appName, "-").concat(env);
|
|
122
127
|
var RELEASE_NAME = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
|
|
123
128
|
var componentSlug = (0, slugify_1["default"])(componentName);
|
|
124
129
|
var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.refSlug, ".").concat(env) : env;
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
var
|
|
128
|
-
|
|
130
|
+
var domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && ((_e = mergedConfig.deploy.cluster) === null || _e === void 0 ? void 0 : _e.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
|
|
131
|
+
config.domainCanonical || "panter.cloud";
|
|
132
|
+
var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical);
|
|
133
|
+
hostname = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.hostname) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
|
|
134
|
+
var url_1 = "https://".concat(hostname); // FIXME: move to kube specific jobs
|
|
135
|
+
|
|
136
|
+
var KUBE_APP_NAME = envType === "review" && commitInfo ? "".concat(commitInfo.refSlug, "-").concat(componentName) : componentName;
|
|
137
|
+
var KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
|
|
129
138
|
predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
|
|
130
139
|
HOST_CANONICAL: HOST_CANONICAL,
|
|
131
140
|
ROOT_URL: url_1,
|
|
@@ -135,12 +144,12 @@ var getEnvironment = function (config, componentName, env, commitInfo, skipRefer
|
|
|
135
144
|
});
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
var publicEnvVars = (
|
|
139
|
-
var secretEnvVarKeys = (
|
|
147
|
+
var publicEnvVars = (_h = (_g = mergedConfig.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
|
|
148
|
+
var secretEnvVarKeys = (_k = (_j = mergedConfig.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : [];
|
|
140
149
|
var secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
|
|
141
150
|
return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
|
|
142
151
|
}));
|
|
143
|
-
var referencedRaw = (
|
|
152
|
+
var referencedRaw = (_m = (_l = mergedConfig.vars) === null || _l === void 0 ? void 0 : _l.fromComponents) !== null && _m !== void 0 ? _m : {};
|
|
144
153
|
var referenced = skipReferences ? {} : Object.entries(referencedRaw).reduce(function (acc, _a) {
|
|
145
154
|
var _b = __read(_a, 2),
|
|
146
155
|
otherApp = _b[0],
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { GitlabJobs } from "../types/gitlab-types";
|
|
2
2
|
import { Context } from "../types/context";
|
|
3
3
|
import { DeployConfig } from "./types";
|
|
4
|
+
export * from "./kubernetes";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export * from "./utils";
|
|
4
7
|
export declare type DeployTypes = { [type in DeployConfig["type"]]: {
|
|
5
8
|
jobs: (context: Context) => GitlabJobs;
|
|
6
9
|
defaults: () => Partial<Extract<DeployConfig, {
|
|
7
10
|
type: type;
|
|
8
11
|
}>>;
|
|
9
12
|
} };
|
|
10
|
-
export * from "./types";
|
|
11
13
|
export declare const DEPLOY_TYPES: DeployTypes;
|
package/dist/deploy/index.js
CHANGED
|
@@ -22,8 +22,12 @@ exports.DEPLOY_TYPES = void 0;
|
|
|
22
22
|
|
|
23
23
|
var kubernetes_1 = require("./kubernetes");
|
|
24
24
|
|
|
25
|
+
__exportStar(require("./kubernetes"), exports);
|
|
26
|
+
|
|
25
27
|
__exportStar(require("./types"), exports);
|
|
26
28
|
|
|
29
|
+
__exportStar(require("./utils"), exports);
|
|
30
|
+
|
|
27
31
|
exports.DEPLOY_TYPES = {
|
|
28
32
|
kubernetes: {
|
|
29
33
|
jobs: kubernetes_1.createKubernetesDeployJobs,
|
|
@@ -8,7 +8,7 @@ var __1 = require("../..");
|
|
|
8
8
|
var createCloudsqlBaseConfig = function (context) {
|
|
9
9
|
return {
|
|
10
10
|
cloudsql: {
|
|
11
|
-
proxyCredentials: "$".concat((0, __1.
|
|
11
|
+
proxyCredentials: "$".concat((0, __1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"))
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -39,6 +39,16 @@ var __read = this && this.__read || function (o, n) {
|
|
|
39
39
|
return ar;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
43
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
44
|
+
if (ar || !(i in from)) {
|
|
45
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
46
|
+
ar[i] = from[i];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
50
|
+
};
|
|
51
|
+
|
|
42
52
|
exports.__esModule = true;
|
|
43
53
|
exports.createKubernetesDeployJobs = void 0;
|
|
44
54
|
|
|
@@ -56,8 +66,10 @@ var mongodb_1 = require("./mongodb");
|
|
|
56
66
|
|
|
57
67
|
var cloudsql_1 = require("./cloudsql");
|
|
58
68
|
|
|
69
|
+
var __1 = require("../..");
|
|
70
|
+
|
|
59
71
|
var createKubernetesDeployJobs = function (context) {
|
|
60
|
-
var _a, _b, _c, _d;
|
|
72
|
+
var _a, _b, _c, _d, _e, _f;
|
|
61
73
|
|
|
62
74
|
var deployConfig = context.componentConfig.deploy;
|
|
63
75
|
|
|
@@ -79,11 +91,13 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
79
91
|
var env = Object.entries(allEnvVars).reduce(function (acc, _a) {
|
|
80
92
|
var _b, _c;
|
|
81
93
|
|
|
82
|
-
var _d
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
var _d;
|
|
95
|
+
|
|
96
|
+
var _e = __read(_a, 2),
|
|
97
|
+
key = _e[0],
|
|
98
|
+
value = _e[1];
|
|
85
99
|
|
|
86
|
-
if (value === null ||
|
|
100
|
+
if ((_d = String(value)) === null || _d === void 0 ? void 0 : _d.startsWith("$CL_")) {
|
|
87
101
|
acc.secret = __assign(__assign({}, acc.secret), (_b = {}, _b[key] = value, _b));
|
|
88
102
|
return acc;
|
|
89
103
|
}
|
|
@@ -119,8 +133,9 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
119
133
|
forceQuotes: true
|
|
120
134
|
}),
|
|
121
135
|
HELM_GITLAB_CHART_NAME: "the-panter-chart",
|
|
122
|
-
HELM_ARGS: deployConfig.additionalHelmArgs,
|
|
136
|
+
HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_e = deployConfig.additionalHelmArgs) !== null && _e !== void 0 ? _e : []), false).join(" "),
|
|
123
137
|
COMPONENT_NAME: context.componentName,
|
|
138
|
+
BUILD_ID: (_f = context.commitInfo) === null || _f === void 0 ? void 0 : _f.buildId,
|
|
124
139
|
// TODO: unify with docker build stage
|
|
125
140
|
IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
|
|
126
141
|
IMAGE_TAG: "$CI_COMMIT_SHA"
|
|
@@ -129,16 +144,18 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
129
144
|
};
|
|
130
145
|
var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
|
|
131
146
|
var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
|
|
147
|
+
var clusterName = "kube-".concat(context.environment.fullName);
|
|
148
|
+
var connectContext = ["kubectl config set-cluster \"".concat(clusterName, "\" --server=\"$").concat((0, __1.getSecretVarNameForContext)(context, "KUBE_URL"), "\" --certificate-authority <(echo $").concat((0, __1.getSecretVarNameForContext)(context, "KUBE_CA_PEM"), " | base64 -d) --embed-certs=true"), "kubectl config set-credentials \"".concat(clusterName, "\" --token=\"$").concat((0, __1.getSecretVarNameForContext)(context, "KUBE_TOKEN"), "\""), "kubectl config set-context \"".concat(clusterName, "\" --cluster=\"").concat(clusterName, "\" --user=\"").concat(clusterName, "\" --namespace=\"").concat(context.environment.envVars.KUBE_NAMESPACE, "\""), "kubectl config use-context \"".concat(clusterName, "\"")];
|
|
132
149
|
return [(0, lodash_1.merge)({}, baseDeploymentJob, shared, {
|
|
133
150
|
job: {
|
|
134
|
-
script: [
|
|
151
|
+
script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesCreateSecret", "kubernetesDeploy", "echo deployment successful 😻"], false),
|
|
135
152
|
environment: {
|
|
136
153
|
kubernetes: kubernetesEnvironment
|
|
137
154
|
}
|
|
138
155
|
}
|
|
139
156
|
}), (0, lodash_1.merge)({}, baseStopJob, shared, {
|
|
140
157
|
job: {
|
|
141
|
-
script: ["kubernetesDelete"],
|
|
158
|
+
script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesDelete"], false),
|
|
142
159
|
environment: {
|
|
143
160
|
kubernetes: kubernetesEnvironment
|
|
144
161
|
}
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -1,35 +1,113 @@
|
|
|
1
1
|
export declare type DeployConfigBase = {};
|
|
2
2
|
declare type AllowUnknownProps<T extends Record<string, unknown>> = T & Record<string, unknown>;
|
|
3
|
+
export declare type DeployConfigKubernetesClusterGCloud = {
|
|
4
|
+
type: "gcloud";
|
|
5
|
+
/**
|
|
6
|
+
* gcoud name of the cluster
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* google cloud project id
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
projectId: string;
|
|
15
|
+
/**
|
|
16
|
+
* region
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
region: string;
|
|
20
|
+
/**
|
|
21
|
+
* domain of the cluster, for canonical domains without custom hostnames (e.g. review and dev apps)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
domainCanonical?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare type DeployConfigKubernetesCluster = DeployConfigKubernetesClusterGCloud;
|
|
3
27
|
export declare type DeployConfigKubernetes = {
|
|
4
28
|
type: "kubernetes";
|
|
5
|
-
|
|
29
|
+
/**
|
|
30
|
+
* cluster config to use.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
cluster: DeployConfigKubernetesCluster;
|
|
34
|
+
/**
|
|
35
|
+
* prints out debug info (helm --debug)
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
debug?: boolean;
|
|
6
39
|
additionalHelmArgs?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* values to configure the app
|
|
42
|
+
*/
|
|
43
|
+
|
|
7
44
|
values?: AllowUnknownProps<{
|
|
45
|
+
/**
|
|
46
|
+
* enable cloudsql db. Currently you have to manually set it up
|
|
47
|
+
*/
|
|
8
48
|
cloudsql?: {
|
|
9
49
|
enabled: boolean;
|
|
10
50
|
instanceId?: string;
|
|
11
51
|
projectId?: string;
|
|
12
52
|
region?: string;
|
|
13
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* enable mongodb. The mongodb is deployed using a helm chart.
|
|
56
|
+
* Consider using external services instead of this.
|
|
57
|
+
*/
|
|
58
|
+
|
|
14
59
|
mongodb?: AllowUnknownProps<{
|
|
15
60
|
enabled: boolean;
|
|
16
61
|
}>;
|
|
62
|
+
/**
|
|
63
|
+
* enable mailhog. Mailhog is a virtual mail server that catches all outgoing mailsl and show them in a mailbox.
|
|
64
|
+
* This is great for development as it prevents to accidentially send out real emails and helps with debugging outgoing mails.
|
|
65
|
+
*
|
|
66
|
+
* It will automaticaly inject a MAIL_URL env var.
|
|
67
|
+
*
|
|
68
|
+
* Turn it of for production.
|
|
69
|
+
*/
|
|
70
|
+
|
|
17
71
|
mailhog?: {
|
|
18
72
|
enabled: boolean;
|
|
19
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* post-install/upgrade jobs. These use the app image and have all env vars available.
|
|
76
|
+
* Typically used for migrations and seeds
|
|
77
|
+
*/
|
|
78
|
+
|
|
20
79
|
jobs?: Record<string, AllowUnknownProps<{
|
|
21
80
|
command: string;
|
|
22
81
|
}>>;
|
|
82
|
+
/**
|
|
83
|
+
* cronjobs that run periodically. These use the app image have all env vars available.
|
|
84
|
+
*/
|
|
85
|
+
|
|
23
86
|
cronjobs?: Record<string, AllowUnknownProps<{
|
|
24
87
|
schedule: string;
|
|
25
88
|
command: string;
|
|
26
89
|
concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
|
|
27
90
|
}>>;
|
|
91
|
+
/**
|
|
92
|
+
* configuration for the application ("Deployment" in kubernetes)
|
|
93
|
+
*/
|
|
94
|
+
|
|
28
95
|
application?: AllowUnknownProps<{
|
|
96
|
+
/**
|
|
97
|
+
* redirects
|
|
98
|
+
*/
|
|
29
99
|
redirects?: AllowUnknownProps<{
|
|
30
100
|
host: string;
|
|
31
101
|
}>[];
|
|
102
|
+
/**
|
|
103
|
+
* how many pods will be started
|
|
104
|
+
*/
|
|
105
|
+
|
|
32
106
|
replicas?: number;
|
|
107
|
+
/**
|
|
108
|
+
* kubernetes resources
|
|
109
|
+
*/
|
|
110
|
+
|
|
33
111
|
resources?: {
|
|
34
112
|
limits?: {
|
|
35
113
|
cpu?: string;
|
|
@@ -46,34 +124,88 @@ export declare type DeployConfigKubernetes = {
|
|
|
46
124
|
export declare type DeployConfig = DeployConfigKubernetes;
|
|
47
125
|
export declare const isOfDeployType: <T extends "kubernetes"[]>(t: DeployConfig | false, ...types: T) => t is Extract<{
|
|
48
126
|
type: "kubernetes";
|
|
49
|
-
|
|
127
|
+
/**
|
|
128
|
+
* cluster config to use.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
cluster: DeployConfigKubernetesCluster;
|
|
132
|
+
/**
|
|
133
|
+
* prints out debug info (helm --debug)
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
debug?: boolean | undefined;
|
|
50
137
|
additionalHelmArgs?: string[] | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* values to configure the app
|
|
140
|
+
*/
|
|
141
|
+
|
|
51
142
|
values?: AllowUnknownProps<{
|
|
143
|
+
/**
|
|
144
|
+
* enable cloudsql db. Currently you have to manually set it up
|
|
145
|
+
*/
|
|
52
146
|
cloudsql?: {
|
|
53
147
|
enabled: boolean;
|
|
54
148
|
instanceId?: string | undefined;
|
|
55
149
|
projectId?: string | undefined;
|
|
56
150
|
region?: string | undefined;
|
|
57
151
|
} | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* enable mongodb. The mongodb is deployed using a helm chart.
|
|
154
|
+
* Consider using external services instead of this.
|
|
155
|
+
*/
|
|
156
|
+
|
|
58
157
|
mongodb?: AllowUnknownProps<{
|
|
59
158
|
enabled: boolean;
|
|
60
159
|
}> | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* enable mailhog. Mailhog is a virtual mail server that catches all outgoing mailsl and show them in a mailbox.
|
|
162
|
+
* This is great for development as it prevents to accidentially send out real emails and helps with debugging outgoing mails.
|
|
163
|
+
*
|
|
164
|
+
* It will automaticaly inject a MAIL_URL env var.
|
|
165
|
+
*
|
|
166
|
+
* Turn it of for production.
|
|
167
|
+
*/
|
|
168
|
+
|
|
61
169
|
mailhog?: {
|
|
62
170
|
enabled: boolean;
|
|
63
171
|
} | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* post-install/upgrade jobs. These use the app image and have all env vars available.
|
|
174
|
+
* Typically used for migrations and seeds
|
|
175
|
+
*/
|
|
176
|
+
|
|
64
177
|
jobs?: Record<string, AllowUnknownProps<{
|
|
65
178
|
command: string;
|
|
66
179
|
}>> | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* cronjobs that run periodically. These use the app image have all env vars available.
|
|
182
|
+
*/
|
|
183
|
+
|
|
67
184
|
cronjobs?: Record<string, AllowUnknownProps<{
|
|
68
185
|
schedule: string;
|
|
69
186
|
command: string;
|
|
70
187
|
concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
|
|
71
188
|
}>> | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* configuration for the application ("Deployment" in kubernetes)
|
|
191
|
+
*/
|
|
192
|
+
|
|
72
193
|
application?: AllowUnknownProps<{
|
|
194
|
+
/**
|
|
195
|
+
* redirects
|
|
196
|
+
*/
|
|
73
197
|
redirects?: AllowUnknownProps<{
|
|
74
198
|
host: string;
|
|
75
199
|
}>[] | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* how many pods will be started
|
|
202
|
+
*/
|
|
203
|
+
|
|
76
204
|
replicas?: number | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* kubernetes resources
|
|
207
|
+
*/
|
|
208
|
+
|
|
77
209
|
resources?: {
|
|
78
210
|
limits?: {
|
|
79
211
|
cpu?: string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Config } from "../types";
|
|
2
|
+
import type { 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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getKubernetesNamespace = exports.getFullKubernetesClusterName = void 0;
|
|
5
|
+
|
|
6
|
+
var getFullKubernetesClusterName = function (cluster) {
|
|
7
|
+
if (cluster.type === "gcloud") {
|
|
8
|
+
return "gke_".concat(cluster.projectId, "_").concat(cluster.region, "_").concat(cluster.name);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.getFullKubernetesClusterName = getFullKubernetesClusterName;
|
|
13
|
+
|
|
14
|
+
var getKubernetesNamespace = function (config, env) {
|
|
15
|
+
return "".concat(config.customerName, "-").concat(config.appName, "-").concat(env);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.getKubernetesNamespace = getKubernetesNamespace;
|
|
@@ -2,6 +2,9 @@ import { Config, PipelineTrigger } from "../types/config";
|
|
|
2
2
|
import { GitlabJobDef } from "../types/gitlab-types";
|
|
3
3
|
export declare const createChildPipeline: (trigger: PipelineTrigger, config: Config) => Promise<{
|
|
4
4
|
image: string;
|
|
5
|
+
variables: {
|
|
6
|
+
FF_USE_FASTZIP: string;
|
|
7
|
+
};
|
|
5
8
|
workflow: {
|
|
6
9
|
rules: import("../types/gitlab-types").GitlabRule[];
|
|
7
10
|
};
|
|
@@ -249,7 +249,10 @@ var createChildPipeline = function (trigger, config) {
|
|
|
249
249
|
})), false);
|
|
250
250
|
}, []);
|
|
251
251
|
childPipeline = __assign({
|
|
252
|
-
image: (0, runner_1.getRunnerImage)("jobs"),
|
|
252
|
+
image: (0, runner_1.getRunnerImage)("jobs-default"),
|
|
253
|
+
variables: {
|
|
254
|
+
FF_USE_FASTZIP: "true"
|
|
255
|
+
},
|
|
253
256
|
workflow: {
|
|
254
257
|
rules: rules_1.RULES_ALWAYS
|
|
255
258
|
},
|
|
@@ -168,7 +168,13 @@ describe("createChildPipeline", function () {
|
|
|
168
168
|
type: "node"
|
|
169
169
|
},
|
|
170
170
|
deploy: {
|
|
171
|
-
type: "kubernetes"
|
|
171
|
+
type: "kubernetes",
|
|
172
|
+
cluster: {
|
|
173
|
+
type: "gcloud",
|
|
174
|
+
name: "mega-cluster",
|
|
175
|
+
projectId: "super-google-project",
|
|
176
|
+
region: "ch-blabla"
|
|
177
|
+
}
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
180
|
}
|