@catladder/pipeline 0.0.0-feat-meteor-6f506099 → 0.0.0-fix-migrate-string-cmd-4e99e207
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 +4 -3
- package/dist/build/index.js +1 -1
- package/dist/build/node/buildJob.js +3 -0
- package/dist/build/node/cache.js +1 -1
- package/dist/build/node/constants.js +1 -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 -1
- package/dist/catladder-gitlab.js +1 -1
- 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 +28 -19
- package/dist/deploy/base.js +11 -4
- package/dist/deploy/index.d.ts +3 -1
- package/dist/deploy/index.js +4 -0
- package/dist/deploy/kubernetes/cloudsql.d.ts +6 -0
- package/dist/deploy/kubernetes/cloudsql.js +16 -0
- package/dist/deploy/kubernetes/deployJob.js +35 -11
- package/dist/deploy/kubernetes/mongodb.d.ts +0 -3
- package/dist/deploy/kubernetes/mongodb.js +2 -4
- 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 +22 -10
- package/dist/runner/index.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +65 -1
- package/dist/types/context.d.ts +4 -2
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +45 -2
- package/package.json +1 -3
- package/src/build/base/createBuildJob.ts +4 -7
- package/src/build/base/getBuildInfo.ts +7 -0
- package/src/build/docker.ts +10 -5
- package/src/build/index.ts +1 -1
- package/src/build/node/buildJob.ts +4 -0
- package/src/build/node/cache.ts +1 -1
- package/src/build/node/constants.ts +1 -1
- package/src/build/node/meteor.ts +2 -0
- package/src/build/tests/storybook.test.ts +6 -0
- package/src/build/types.ts +6 -1
- package/src/catladder-gitlab.ts +2 -1
- package/src/config/configruedEnvs.test.ts +10 -3
- package/src/context/index.ts +29 -14
- package/src/deploy/base.ts +10 -4
- package/src/deploy/index.ts +3 -2
- package/src/deploy/kubernetes/cloudsql.ts +12 -0
- package/src/deploy/kubernetes/deployJob.ts +42 -8
- package/src/deploy/kubernetes/mongodb.ts +16 -21
- 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 +6 -1
- package/src/runner/index.ts +3 -1
- package/src/types/config.ts +57 -1
- package/src/types/context.ts +4 -2
- package/src/utils/index.ts +10 -1
|
@@ -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,
|
|
@@ -83,12 +84,12 @@ var createDockerBuildJob = function (context, _a) {
|
|
|
83
84
|
DOCKER_DIR: ".",
|
|
84
85
|
IMAGE_TAG: "$CI_COMMIT_SHA",
|
|
85
86
|
DOCKER_DRIVER: "overlay2",
|
|
86
|
-
IMAGE_NAME: "$CI_REGISTRY_IMAGE/" + context.componentName,
|
|
87
|
-
CACHE_IMAGE: "$CI_REGISTRY_IMAGE/" + context.componentName
|
|
87
|
+
IMAGE_NAME: "$CI_REGISTRY_IMAGE/" + context.environment.shortName + "/" + context.componentName,
|
|
88
|
+
CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName
|
|
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
|
|
package/dist/build/index.js
CHANGED
|
@@ -64,6 +64,8 @@ var types_1 = require("../types");
|
|
|
64
64
|
|
|
65
65
|
var cache_1 = require("./cache");
|
|
66
66
|
|
|
67
|
+
var constants_2 = require("./constants");
|
|
68
|
+
|
|
67
69
|
var yarn_1 = require("./yarn");
|
|
68
70
|
|
|
69
71
|
var createNodeBuildJobs = function (context) {
|
|
@@ -77,6 +79,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
77
79
|
|
|
78
80
|
var yarnInstall = (0, yarn_1.getYarnInstall)(context);
|
|
79
81
|
var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
|
|
82
|
+
variables: __assign({}, constants_2.NODE_RUNNER_BUILD_VARIABLES),
|
|
80
83
|
cache: __spreadArray(__spreadArray([], __read((0, cache_1.getNodeCache)(context)), false), __read((0, cache_1.getNextCache)(context)), false),
|
|
81
84
|
script: __spreadArray(__spreadArray([], __read(yarnInstall), false), __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
|
|
82
85
|
artifacts: {
|
package/dist/build/node/cache.js
CHANGED
|
@@ -46,7 +46,7 @@ var getNodeCache = function (context) {
|
|
|
46
46
|
var componentIsInWorkspace = (_a = context.yarnInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace;
|
|
47
47
|
return [{
|
|
48
48
|
// if component is in a shared workspace, use workspace cache. use individual cache else
|
|
49
|
-
key: componentIsInWorkspace ? "node-modules-workspace" : context.
|
|
49
|
+
key: componentIsInWorkspace ? "node-modules-workspace" : context.componentConfig.dir + "-node-modules",
|
|
50
50
|
policy: "pull-push",
|
|
51
51
|
paths: __spreadArray([".yarn"], __read(componentIsInWorkspace ? __spreadArray(["node_modules"], __read((_c = (_b = context.yarnInfo) === null || _b === void 0 ? void 0 : _b.workspaces.map(function (w) {
|
|
52
52
|
return (0, path_1.join)(w.location, "node_modules");
|
|
@@ -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
|
|
@@ -46,7 +53,6 @@ export declare type BuildConfigNodeStatic = BuildConfigNodeBase & {
|
|
|
46
53
|
};
|
|
47
54
|
export declare type BuildConfigMeteor = BuildConfigNodeBase & {
|
|
48
55
|
type: "meteor";
|
|
49
|
-
startCommand: "node main.js";
|
|
50
56
|
};
|
|
51
57
|
export declare type BuildConfigStorybook = BuildConfigNodeBase & {
|
|
52
58
|
type: "storybook";
|
package/dist/catladder-gitlab.js
CHANGED
|
@@ -15,7 +15,7 @@ var _a = process.env,
|
|
|
15
15
|
CI_COMMIT_TAG = _a.CI_COMMIT_TAG,
|
|
16
16
|
CI_COMMIT_BRANCH = _a.CI_COMMIT_BRANCH,
|
|
17
17
|
CI_DEFAULT_BRANCH = _a.CI_DEFAULT_BRANCH;
|
|
18
|
-
var isDefaultBranch = CI_COMMIT_BRANCH
|
|
18
|
+
var isDefaultBranch = Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
|
|
19
19
|
var isHotfixBranch = false; // TODO: $CI_COMMIT_BRANCH =~ /^[0-9]+\.([0-9]+|x)\.x$/
|
|
20
20
|
|
|
21
21
|
var isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
|
|
@@ -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 = "
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "fix-migrate-string-cmd-4e99e207" || "";
|
|
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,9 +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;
|
|
50
|
-
|
|
51
|
-
var lodash_1 = require("lodash");
|
|
49
|
+
exports.createContext = exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
|
|
52
50
|
|
|
53
51
|
var slugify_1 = __importDefault(require("slugify"));
|
|
54
52
|
|
|
@@ -58,6 +56,8 @@ var deploy_1 = require("../deploy");
|
|
|
58
56
|
|
|
59
57
|
var config_1 = require("../types/config");
|
|
60
58
|
|
|
59
|
+
var utils_1 = require("../utils");
|
|
60
|
+
|
|
61
61
|
var sanitizeForEnVar = function (s) {
|
|
62
62
|
return s.replace(/-/g, "_");
|
|
63
63
|
};
|
|
@@ -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;
|
|
@@ -90,7 +96,7 @@ var getEnvironment = function (config, componentName, env, commitInfo, skipRefer
|
|
|
90
96
|
throw new Error("env is disabled: " + env);
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
var mergedConfig = (0,
|
|
99
|
+
var mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig); // env type: if its set manually, use that, otherwise use the known env types
|
|
94
100
|
|
|
95
101
|
var basePredefinedVariables = {
|
|
96
102
|
ENV_SHORT: env,
|
|
@@ -105,27 +111,30 @@ var getEnvironment = function (config, componentName, env, commitInfo, skipRefer
|
|
|
105
111
|
var environmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
|
|
106
112
|
var environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.refSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
|
|
107
113
|
var predefinedVariables;
|
|
108
|
-
var
|
|
114
|
+
var host;
|
|
109
115
|
var url;
|
|
110
116
|
|
|
111
117
|
if (envType === "local") {
|
|
112
118
|
var devLocalConfig = mergedConfig;
|
|
113
119
|
var port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
|
|
114
|
-
|
|
115
|
-
url = "http://" +
|
|
120
|
+
host = "localhost:" + port;
|
|
121
|
+
url = "http://" + host;
|
|
116
122
|
predefinedVariables = {
|
|
117
123
|
ROOT_URL: url,
|
|
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
|
+
host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
|
|
134
|
+
var url_1 = "https://".concat(host); // 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],
|
|
@@ -161,7 +170,7 @@ var getEnvironment = function (config, componentName, env, commitInfo, skipRefer
|
|
|
161
170
|
|
|
162
171
|
return {
|
|
163
172
|
envType: envType,
|
|
164
|
-
|
|
173
|
+
host: host,
|
|
165
174
|
fullName: environmentName,
|
|
166
175
|
slug: environmentSlug,
|
|
167
176
|
shortName: env,
|
|
@@ -188,7 +197,7 @@ var createContext = function (config, componentName, env, commitInfo, yarnInfo)
|
|
|
188
197
|
|
|
189
198
|
|
|
190
199
|
var envConfig = (_b = (_a = rawConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
|
|
191
|
-
var componentConfigWithoutDefaults = (0,
|
|
200
|
+
var componentConfigWithoutDefaults = (0, utils_1.mergeWithMergingArrays)(rawConfig, envConfig); // fill in defaults of build and deploy
|
|
192
201
|
|
|
193
202
|
var defaults = componentConfigWithoutDefaults.deploy ? {
|
|
194
203
|
build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(),
|
|
@@ -197,7 +206,7 @@ var createContext = function (config, componentName, env, commitInfo, yarnInfo)
|
|
|
197
206
|
build: {},
|
|
198
207
|
deploy: {}
|
|
199
208
|
};
|
|
200
|
-
var componentConfig = (0,
|
|
209
|
+
var componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
|
|
201
210
|
return {
|
|
202
211
|
fullConfig: config,
|
|
203
212
|
componentConfig: componentConfig,
|
package/dist/deploy/base.js
CHANGED
|
@@ -26,11 +26,18 @@ var DEPLOY_RUNNER_VARIABLES = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
var getBaseDeploymentJob = function (context) {
|
|
29
|
+
var _a;
|
|
30
|
+
|
|
29
31
|
var environment = {
|
|
30
32
|
name: context.environment.fullName,
|
|
31
33
|
url: context.environment.url
|
|
32
34
|
};
|
|
33
|
-
var autoStop = context.environment.envType === "review" ? "2 weeks" : context.environment.envType === "dev" ? "3 weeks" : undefined;
|
|
35
|
+
var autoStop = context.environment.envType === "review" ? "2 weeks" : context.environment.envType === "dev" ? "3 weeks" : undefined; // automatically run deploy job, unless its prod and stage is active
|
|
36
|
+
|
|
37
|
+
var autoDeploy = context.environment.envType !== "prod" ? true // is not stage, auto deploy
|
|
38
|
+
: ((_a = context.componentConfig.env) === null || _a === void 0 ? void 0 : _a.stage) === false ? true // is prod, but no staging, auto deploy
|
|
39
|
+
: false; // manually deploy
|
|
40
|
+
|
|
34
41
|
return {
|
|
35
42
|
name: exports.DEPLOY_JOB_NAME,
|
|
36
43
|
envMode: "stagePerEnv",
|
|
@@ -43,10 +50,10 @@ var getBaseDeploymentJob = function (context) {
|
|
|
43
50
|
artifacts: false
|
|
44
51
|
}],
|
|
45
52
|
job: {
|
|
46
|
-
rules: [
|
|
47
|
-
when: "manual"
|
|
48
|
-
} : {
|
|
53
|
+
rules: [autoDeploy ? {
|
|
49
54
|
when: "on_success"
|
|
55
|
+
} : {
|
|
56
|
+
when: "manual"
|
|
50
57
|
}],
|
|
51
58
|
stage: "deploy",
|
|
52
59
|
dependencies: [],
|
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,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.createCloudsqlBaseConfig = void 0;
|
|
5
|
+
|
|
6
|
+
var __1 = require("../..");
|
|
7
|
+
|
|
8
|
+
var createCloudsqlBaseConfig = function (context) {
|
|
9
|
+
return {
|
|
10
|
+
cloudsql: {
|
|
11
|
+
proxyCredentials: "$".concat((0, __1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"))
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.createCloudsqlBaseConfig = createCloudsqlBaseConfig;
|
|
@@ -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
|
|
|
@@ -54,7 +64,15 @@ var js_yaml_1 = require("js-yaml");
|
|
|
54
64
|
|
|
55
65
|
var mongodb_1 = require("./mongodb");
|
|
56
66
|
|
|
67
|
+
var cloudsql_1 = require("./cloudsql");
|
|
68
|
+
|
|
69
|
+
var __1 = require("../..");
|
|
70
|
+
|
|
71
|
+
var utils_1 = require("../../utils");
|
|
72
|
+
|
|
57
73
|
var createKubernetesDeployJobs = function (context) {
|
|
74
|
+
var _a, _b, _c, _d, _e, _f;
|
|
75
|
+
|
|
58
76
|
var deployConfig = context.componentConfig.deploy;
|
|
59
77
|
|
|
60
78
|
if (deployConfig === false) {
|
|
@@ -75,11 +93,13 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
75
93
|
var env = Object.entries(allEnvVars).reduce(function (acc, _a) {
|
|
76
94
|
var _b, _c;
|
|
77
95
|
|
|
78
|
-
var _d
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
var _d;
|
|
97
|
+
|
|
98
|
+
var _e = __read(_a, 2),
|
|
99
|
+
key = _e[0],
|
|
100
|
+
value = _e[1];
|
|
81
101
|
|
|
82
|
-
if (value === null ||
|
|
102
|
+
if ((_d = String(value)) === null || _d === void 0 ? void 0 : _d.startsWith("$CL_")) {
|
|
83
103
|
acc.secret = __assign(__assign({}, acc.secret), (_b = {}, _b[key] = value, _b));
|
|
84
104
|
return acc;
|
|
85
105
|
}
|
|
@@ -91,15 +111,15 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
91
111
|
public: {}
|
|
92
112
|
});
|
|
93
113
|
|
|
94
|
-
var defaultKubeValues = __assign({
|
|
114
|
+
var defaultKubeValues = __assign(__assign({
|
|
95
115
|
application: {
|
|
96
|
-
|
|
116
|
+
host: context.environment.host,
|
|
97
117
|
command: context.componentConfig.build.startCommand
|
|
98
118
|
},
|
|
99
119
|
env: env
|
|
100
|
-
}, (0, mongodb_1.createMongodbBaseConfig)(context));
|
|
120
|
+
}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.cloudsql) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, cloudsql_1.createCloudsqlBaseConfig)(context) : {}), ((_d = (_c = deployConfig.values) === null || _c === void 0 ? void 0 : _c.mongodb) === null || _d === void 0 ? void 0 : _d.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
|
|
101
121
|
|
|
102
|
-
var kubeValues = (0,
|
|
122
|
+
var kubeValues = (0, utils_1.mergeWithMergingArrays)(defaultKubeValues, deployConfig.values);
|
|
103
123
|
var kubernetesEnvironment = {
|
|
104
124
|
namespace: context.environment.envVars.KUBE_NAMESPACE
|
|
105
125
|
};
|
|
@@ -115,25 +135,29 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
115
135
|
forceQuotes: true
|
|
116
136
|
}),
|
|
117
137
|
HELM_GITLAB_CHART_NAME: "the-panter-chart",
|
|
118
|
-
HELM_ARGS: deployConfig.additionalHelmArgs,
|
|
138
|
+
HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_e = deployConfig.additionalHelmArgs) !== null && _e !== void 0 ? _e : []), false).join(" "),
|
|
119
139
|
COMPONENT_NAME: context.componentName,
|
|
140
|
+
BUILD_ID: (_f = context.commitInfo) === null || _f === void 0 ? void 0 : _f.buildId,
|
|
120
141
|
// TODO: unify with docker build stage
|
|
142
|
+
IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
|
|
121
143
|
IMAGE_TAG: "$CI_COMMIT_SHA"
|
|
122
144
|
})
|
|
123
145
|
}
|
|
124
146
|
};
|
|
125
147
|
var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
|
|
126
148
|
var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
|
|
149
|
+
var clusterName = "kube-".concat(context.environment.fullName);
|
|
150
|
+
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, "\"")];
|
|
127
151
|
return [(0, lodash_1.merge)({}, baseDeploymentJob, shared, {
|
|
128
152
|
job: {
|
|
129
|
-
script: [
|
|
153
|
+
script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesCreateSecret", "kubernetesDeploy", "echo deployment successful 😻"], false),
|
|
130
154
|
environment: {
|
|
131
155
|
kubernetes: kubernetesEnvironment
|
|
132
156
|
}
|
|
133
157
|
}
|
|
134
158
|
}), (0, lodash_1.merge)({}, baseStopJob, shared, {
|
|
135
159
|
job: {
|
|
136
|
-
script: ["kubernetesDelete"],
|
|
160
|
+
script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesDelete"], false),
|
|
137
161
|
environment: {
|
|
138
162
|
kubernetes: kubernetesEnvironment
|
|
139
163
|
}
|
|
@@ -4,9 +4,7 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.createMongodbBaseConfig = void 0;
|
|
5
5
|
|
|
6
6
|
var createMongodbBaseConfig = function (context) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return context.componentConfig.deploy && ((_b = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? {
|
|
7
|
+
return {
|
|
10
8
|
mongodb: {
|
|
11
9
|
enabled: true,
|
|
12
10
|
backup: {
|
|
@@ -19,7 +17,7 @@ var createMongodbBaseConfig = function (context) {
|
|
|
19
17
|
storageClass: ["prod", "stage"].includes(context.environment.envType) ? "fast" : "standard"
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
|
-
}
|
|
20
|
+
};
|
|
23
21
|
};
|
|
24
22
|
|
|
25
23
|
exports.createMongodbBaseConfig = createMongodbBaseConfig;
|