@catladder/pipeline 0.0.0-vars-07a720d0 → 0.0.0-waitfor-deploy-e64a33ba
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/base/createBuildJob.js +3 -1
- package/dist/build/docker.d.ts +1 -0
- package/dist/build/docker.js +19 -1
- package/dist/build/index.js +1 -1
- package/dist/build/node/buildJob.js +2 -2
- package/dist/build/node/yarn.d.ts +1 -0
- package/dist/build/node/yarn.js +43 -2
- package/dist/catladder-gitlab.js +8 -6
- package/dist/config/readConfig.d.ts +5 -1
- package/dist/config/readConfig.js +20 -5
- package/dist/constants.js +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +14 -8
- package/dist/context/resolveReferences.d.ts +1 -1
- package/dist/context/resolveReferences.js +9 -4
- package/dist/deploy/base.js +29 -10
- package/dist/deploy/custom/deployJob.d.ts +3 -0
- package/dist/deploy/custom/deployJob.js +65 -0
- package/dist/deploy/custom/index.d.ts +1 -0
- package/dist/deploy/custom/index.js +22 -0
- package/dist/deploy/index.js +8 -0
- package/dist/deploy/kubernetes/deployJob.js +3 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +87 -0
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +39 -0
- package/dist/deploy/types.d.ts +58 -21
- package/dist/deploy/utils.d.ts +4 -3
- package/dist/deploy/utils.js +20 -2
- package/dist/pipeline/createJobs.js +59 -15
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +12 -0
- package/dist/types/context.d.ts +1 -1
- package/dist/types/jobs.d.ts +6 -1
- package/package.json +1 -1
- package/src/build/base/createBuildJob.ts +2 -0
- package/src/build/docker.ts +14 -0
- package/src/build/index.ts +1 -1
- package/src/build/node/buildJob.ts +29 -24
- package/src/build/node/yarn.ts +5 -1
- package/src/catladder-gitlab.ts +1 -1
- package/src/config/readConfig.ts +18 -6
- package/src/context/index.ts +14 -8
- package/src/context/resolveReferences.ts +16 -12
- package/src/deploy/base.ts +36 -11
- package/src/deploy/custom/deployJob.ts +23 -0
- package/src/deploy/custom/index.ts +1 -0
- package/src/deploy/index.ts +5 -0
- package/src/deploy/kubernetes/deployJob.ts +4 -3
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +34 -0
- package/src/deploy/types.ts +53 -4
- package/src/deploy/utils.ts +15 -2
- package/src/pipeline/createJobs.ts +50 -16
- package/src/types/config.ts +12 -0
- package/src/types/context.ts +1 -1
- package/src/types/jobs.ts +7 -1
|
@@ -69,6 +69,8 @@ var __1 = require("../..");
|
|
|
69
69
|
|
|
70
70
|
var utils_1 = require("../../utils");
|
|
71
71
|
|
|
72
|
+
var yarn_1 = require("../node/yarn");
|
|
73
|
+
|
|
72
74
|
var constants_1 = require("./constants");
|
|
73
75
|
|
|
74
76
|
var getBuildInfo_1 = require("./getBuildInfo");
|
|
@@ -88,7 +90,7 @@ var createBuildJob = function (context, _a) {
|
|
|
88
90
|
needs: [],
|
|
89
91
|
cache: [],
|
|
90
92
|
variables: __assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
|
|
91
|
-
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),
|
|
93
|
+
script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, getBuildInfo_1.getBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
|
|
92
94
|
artifacts: {
|
|
93
95
|
paths: [context.componentConfig.dir + "/__build_info.json"]
|
|
94
96
|
}
|
package/dist/build/docker.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context } from "../types";
|
|
2
2
|
import { CatladderJob } from "../types/jobs";
|
|
3
|
+
export declare const requiresDockerBuild: (context: Context) => boolean;
|
|
3
4
|
export declare const getDockerBuildVariables: (context: Context) => {
|
|
4
5
|
DOCKER_BUILDKIT: string;
|
|
5
6
|
DOCKERFILE_ADDITIONS: string | undefined;
|
package/dist/build/docker.js
CHANGED
|
@@ -61,10 +61,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
exports.__esModule = true;
|
|
64
|
-
exports.createDockerBuildJobDefault = exports.createDockerBuildJobBase = exports.DOCKER_BUILD_JOB_NAME = exports.getDockerBuildVariables = void 0;
|
|
64
|
+
exports.createDockerBuildJobDefault = exports.createDockerBuildJobBase = exports.DOCKER_BUILD_JOB_NAME = exports.getDockerBuildVariables = exports.requiresDockerBuild = void 0;
|
|
65
65
|
|
|
66
66
|
var lodash_1 = require("lodash");
|
|
67
67
|
|
|
68
|
+
var deploy_1 = require("../deploy");
|
|
69
|
+
|
|
68
70
|
var runner_1 = require("../runner");
|
|
69
71
|
|
|
70
72
|
var DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
@@ -74,6 +76,22 @@ var DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
|
74
76
|
KUBERNETES_MEMORY_LIMIT: "2Gi"
|
|
75
77
|
};
|
|
76
78
|
|
|
79
|
+
var requiresDockerBuild = function (context) {
|
|
80
|
+
var deployConfig = context.componentConfig.deploy;
|
|
81
|
+
|
|
82
|
+
if ((0, deploy_1.isOfDeployType)(deployConfig, "kubernetes")) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ((0, deploy_1.isOfDeployType)(deployConfig, "custom") && deployConfig.requiresDocker) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
exports.requiresDockerBuild = requiresDockerBuild;
|
|
94
|
+
|
|
77
95
|
var getDockerBuildVariables = function (context) {
|
|
78
96
|
var _a, _b, _c, _d;
|
|
79
97
|
|
package/dist/build/index.js
CHANGED
|
@@ -90,7 +90,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
90
90
|
})) !== null && _c !== void 0 ? _c : []), false)
|
|
91
91
|
}
|
|
92
92
|
}) : null;
|
|
93
|
-
return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), [(0, docker_1.createDockerBuildJobDefault)(context, {
|
|
93
|
+
return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
|
|
94
94
|
script: [buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"],
|
|
95
95
|
cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
|
|
96
96
|
variables: {
|
|
@@ -107,7 +107,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
107
107
|
})) === null || _e === void 0 ? void 0 : _e.join("\n")
|
|
108
108
|
},
|
|
109
109
|
needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
|
|
110
|
-
})], false);
|
|
110
|
+
})] : []), false);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
exports.createNodeBuildJobs = createNodeBuildJobs;
|
|
@@ -3,4 +3,5 @@ export declare const getYarnInstallCommand: (context: Context, options?: {
|
|
|
3
3
|
prodOnly?: boolean | undefined;
|
|
4
4
|
noScripts?: boolean | undefined;
|
|
5
5
|
} | undefined) => string;
|
|
6
|
+
export declare const ensureNodeVersion: (context: Context) => string[];
|
|
6
7
|
export declare const getYarnInstall: (context: Context) => string[];
|
package/dist/build/node/yarn.js
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
e = {
|
|
15
|
+
error: error
|
|
16
|
+
};
|
|
17
|
+
} finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
} finally {
|
|
21
|
+
if (e) throw e.error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
|
|
3
38
|
exports.__esModule = true;
|
|
4
|
-
exports.getYarnInstall = exports.getYarnInstallCommand = void 0;
|
|
39
|
+
exports.getYarnInstall = exports.ensureNodeVersion = exports.getYarnInstallCommand = void 0;
|
|
5
40
|
|
|
6
41
|
var getYarnInstallCommand = function (context, options) {
|
|
7
42
|
var _a;
|
|
@@ -12,8 +47,14 @@ var getYarnInstallCommand = function (context, options) {
|
|
|
12
47
|
|
|
13
48
|
exports.getYarnInstallCommand = getYarnInstallCommand;
|
|
14
49
|
|
|
50
|
+
var ensureNodeVersion = function (context) {
|
|
51
|
+
return ["if [ -f ./.nvmrc ]; then source /root/.nvm/nvm.sh && nvm install <<< .nvmrc; fi"];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.ensureNodeVersion = ensureNodeVersion;
|
|
55
|
+
|
|
15
56
|
var getYarnInstall = function (context) {
|
|
16
|
-
return [
|
|
57
|
+
return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [(0, exports.getYarnInstallCommand)(context)], false);
|
|
17
58
|
};
|
|
18
59
|
|
|
19
60
|
exports.getYarnInstall = getYarnInstall;
|
package/dist/catladder-gitlab.js
CHANGED
|
@@ -25,6 +25,8 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
var _a;
|
|
29
|
+
|
|
28
30
|
exports.__esModule = true;
|
|
29
31
|
|
|
30
32
|
var fs_1 = require("fs");
|
|
@@ -37,11 +39,11 @@ var constants_1 = require("./constants");
|
|
|
37
39
|
|
|
38
40
|
var pipeline_1 = require("./pipeline");
|
|
39
41
|
|
|
40
|
-
var
|
|
41
|
-
CI_MERGE_REQUEST_ID =
|
|
42
|
-
CI_COMMIT_TAG =
|
|
43
|
-
CI_COMMIT_BRANCH =
|
|
44
|
-
CI_DEFAULT_BRANCH =
|
|
42
|
+
var _b = process.env,
|
|
43
|
+
CI_MERGE_REQUEST_ID = _b.CI_MERGE_REQUEST_ID,
|
|
44
|
+
CI_COMMIT_TAG = _b.CI_COMMIT_TAG,
|
|
45
|
+
CI_COMMIT_BRANCH = _b.CI_COMMIT_BRANCH,
|
|
46
|
+
CI_DEFAULT_BRANCH = _b.CI_DEFAULT_BRANCH;
|
|
45
47
|
var isDefaultBranch = Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
|
|
46
48
|
var isHotfixBranch = false; // TODO: $CI_COMMIT_BRANCH =~ /^[0-9]+\.([0-9]+|x)\.x$/
|
|
47
49
|
|
|
@@ -51,7 +53,7 @@ console.info("catladder version ".concat(constants_1.PIPELINE_IMAGE_TAG));
|
|
|
51
53
|
var trigger = isMergeRequest || isHotfixBranch ? "mr" : isDefaultBranch ? "mainBranch" : isTaggedRelease ? "taggedRelease" : null;
|
|
52
54
|
|
|
53
55
|
if (trigger) {
|
|
54
|
-
var config = (0, config_1.readConfigSync)();
|
|
56
|
+
var config = (_a = (0, config_1.readConfigSync)()) === null || _a === void 0 ? void 0 : _a.config;
|
|
55
57
|
|
|
56
58
|
if (!config) {
|
|
57
59
|
throw new Error("no catladder config found");
|
|
@@ -14,6 +14,11 @@ var fullPath = function (directory, ext) {
|
|
|
14
14
|
return directory + "/catladder." + ext;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
function requireUncached(module) {
|
|
18
|
+
delete require.cache[require.resolve(module)];
|
|
19
|
+
return require(module);
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
var readConfigSync = function (directory) {
|
|
18
23
|
if (directory === void 0) {
|
|
19
24
|
directory = process.cwd();
|
|
@@ -31,13 +36,23 @@ var readConfigSync = function (directory) {
|
|
|
31
36
|
});
|
|
32
37
|
|
|
33
38
|
if (found) {
|
|
39
|
+
var filePath = fullPath(directory, found);
|
|
40
|
+
|
|
34
41
|
if (found === "ts" || found === "js") {
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
return {
|
|
43
|
+
path: filePath,
|
|
44
|
+
ext: found,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
46
|
+
config: requireUncached(filePath)["default"]
|
|
47
|
+
};
|
|
37
48
|
} else {
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
return {
|
|
50
|
+
path: filePath,
|
|
51
|
+
ext: found,
|
|
52
|
+
config: (0, js_yaml_1.load)((0, fs_1.readFileSync)(filePath, {
|
|
53
|
+
encoding: "utf-8"
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
41
56
|
}
|
|
42
57
|
}
|
|
43
58
|
|
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 = "waitfor-deploy-e64a33ba" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
package/dist/context/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { Config } from "../types/config";
|
|
|
2
2
|
import { CommitInfo, Context, Environment } from "../types/context";
|
|
3
3
|
export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
|
|
4
4
|
export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
|
|
5
|
-
export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined) => Environment;
|
|
5
|
+
export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Environment;
|
|
6
6
|
export declare const createContext: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, packageManagerInfo?: import("../types/context").YarnPackageManagerInfo | undefined) => Context;
|
package/dist/context/index.js
CHANGED
|
@@ -79,9 +79,14 @@ var getSecretVarNameForContext = function (context, key) {
|
|
|
79
79
|
|
|
80
80
|
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
|
81
81
|
|
|
82
|
-
var getEnvironment = function (config, componentName, env, commitInfo
|
|
82
|
+
var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
|
|
83
|
+
) {
|
|
83
84
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
84
85
|
|
|
86
|
+
if (alreadyVisited === void 0) {
|
|
87
|
+
alreadyVisited = {};
|
|
88
|
+
}
|
|
89
|
+
|
|
85
90
|
var componentConfig = config.components[componentName];
|
|
86
91
|
|
|
87
92
|
if (!componentConfig) {
|
|
@@ -109,7 +114,7 @@ var getEnvironment = function (config, componentName, env, commitInfo) {
|
|
|
109
114
|
ENV_TYPE: envType
|
|
110
115
|
};
|
|
111
116
|
var environmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
|
|
112
|
-
var environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.
|
|
117
|
+
var environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
|
|
113
118
|
var predefinedVariables;
|
|
114
119
|
var host;
|
|
115
120
|
var url;
|
|
@@ -120,20 +125,21 @@ var getEnvironment = function (config, componentName, env, commitInfo) {
|
|
|
120
125
|
host = "localhost:" + port;
|
|
121
126
|
url = "http://" + host;
|
|
122
127
|
predefinedVariables = {
|
|
128
|
+
ENV_SHORT: "local",
|
|
123
129
|
ROOT_URL: url,
|
|
124
130
|
PORT: port.toString()
|
|
125
131
|
};
|
|
126
132
|
} else {
|
|
127
133
|
var RELEASE_NAME = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
|
|
128
134
|
var componentSlug = (0, slugify_1["default"])(componentName);
|
|
129
|
-
var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.
|
|
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
|
|
135
|
+
var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
|
|
136
|
+
var domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy.type) === "kubernetes" && ((_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
137
|
config.domainCanonical || "panter.cloud";
|
|
132
138
|
var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical);
|
|
133
139
|
host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
|
|
134
140
|
var url_1 = "https://".concat(host); // FIXME: move to kube specific jobs
|
|
135
141
|
|
|
136
|
-
var KUBE_APP_NAME = envType === "review" && commitInfo ? "".concat(commitInfo.
|
|
142
|
+
var KUBE_APP_NAME = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-").concat(componentName) : componentName;
|
|
137
143
|
var KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
|
|
138
144
|
predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
|
|
139
145
|
HOST_CANONICAL: HOST_CANONICAL,
|
|
@@ -162,10 +168,10 @@ var getEnvironment = function (config, componentName, env, commitInfo) {
|
|
|
162
168
|
|
|
163
169
|
var envVarsRaw = __assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized);
|
|
164
170
|
|
|
165
|
-
var envVars = (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName) {
|
|
166
|
-
var envVars = (0, exports.getEnvironment)(config, componentName, env, commitInfo).envVars;
|
|
171
|
+
var envVars = (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
|
|
172
|
+
var envVars = (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited).envVars;
|
|
167
173
|
return envVars[variableName];
|
|
168
|
-
});
|
|
174
|
+
}, alreadyVisited);
|
|
169
175
|
return {
|
|
170
176
|
envType: envType,
|
|
171
177
|
host: host,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const resolveReferences: (vars: Record<string, string>, getOtherVariables?: ((componentName: string, variableName: string) => string | null) | undefined) => {
|
|
1
|
+
export declare const resolveReferences: (vars: Record<string, string>, getOtherVariables?: ((componentName: string, variableName: string, alreadyVisited: Record<string, Record<string, boolean>>) => string | null) | undefined, alreadyVisitedBase?: Record<string, Record<string, boolean>>) => {
|
|
2
2
|
[k: string]: string;
|
|
3
3
|
};
|
|
4
4
|
export declare const translateLegacyFromComponents: (fromComponents: Record<string, Record<string, string>>) => {
|
|
@@ -32,10 +32,14 @@ var lodash_1 = require("lodash");
|
|
|
32
32
|
|
|
33
33
|
var REGEX = /\$\{(([^:]+):)?([^}]+)}/gm;
|
|
34
34
|
|
|
35
|
-
var resolveReferences = function (vars, getOtherVariables) {
|
|
35
|
+
var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
|
|
36
|
+
if (alreadyVisitedBase === void 0) {
|
|
37
|
+
alreadyVisitedBase = {};
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
var replaceSingleValue = function (value, alreadyVisited) {
|
|
37
41
|
if (alreadyVisited === void 0) {
|
|
38
|
-
alreadyVisited =
|
|
42
|
+
alreadyVisited = alreadyVisitedBase;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
if (REGEX.test(value)) {
|
|
@@ -48,9 +52,10 @@ var resolveReferences = function (vars, getOtherVariables) {
|
|
|
48
52
|
return match; // prevent endless loop
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
var
|
|
55
|
+
var newAlreadyVisited = (0, lodash_1.merge)({}, alreadyVisited, (_a = {}, _a[componentName] = (_b = {}, _b[variableName] = true, _b), _a));
|
|
56
|
+
var result = componentName ? (_d = getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, variableName, newAlreadyVisited)) !== null && _d !== void 0 ? _d : null : vars[variableName]; // is self reference
|
|
52
57
|
|
|
53
|
-
var replaced = result !== null && result !== undefined ? replaceSingleValue(result,
|
|
58
|
+
var replaced = result !== null && result !== undefined ? replaceSingleValue(result, newAlreadyVisited) : match;
|
|
54
59
|
return replaced;
|
|
55
60
|
});
|
|
56
61
|
} else {
|
package/dist/deploy/base.js
CHANGED
|
@@ -16,6 +16,11 @@ var __assign = this && this.__assign || function () {
|
|
|
16
16
|
|
|
17
17
|
exports.__esModule = true;
|
|
18
18
|
exports.getBaseDeploymentStopJob = exports.getBaseDeploymentJob = exports.STOP_JOB_NAME = exports.DEPLOY_JOB_NAME = void 0;
|
|
19
|
+
|
|
20
|
+
var docker_1 = require("../build/docker");
|
|
21
|
+
|
|
22
|
+
var utils_1 = require("./utils");
|
|
23
|
+
|
|
19
24
|
exports.DEPLOY_JOB_NAME = "🚀 Deploy";
|
|
20
25
|
exports.STOP_JOB_NAME = "🛑 Stop ⚠️";
|
|
21
26
|
var DEPLOY_RUNNER_VARIABLES = {
|
|
@@ -26,40 +31,54 @@ var DEPLOY_RUNNER_VARIABLES = {
|
|
|
26
31
|
};
|
|
27
32
|
|
|
28
33
|
var getBaseDeploymentJob = function (context) {
|
|
29
|
-
var _a;
|
|
34
|
+
var _a, _b, _c;
|
|
30
35
|
|
|
31
36
|
var environment = {
|
|
32
37
|
name: context.environment.fullName,
|
|
33
38
|
url: context.environment.url
|
|
34
39
|
};
|
|
35
|
-
var
|
|
40
|
+
var hasDocker = (0, docker_1.requiresDockerBuild)(context);
|
|
41
|
+
var isStoppable = (0, utils_1.contextIsStoppable)(context);
|
|
42
|
+
var autoStop = context.environment.envType === "review" ? "3 days" // auto stop is not working properly when branch is merged, so we do
|
|
43
|
+
: context.environment.envType === "dev" ? "3 weeks" : undefined; // if auto or manual is configured explicitly, use that
|
|
44
|
+
|
|
45
|
+
var whenDeployDefined = context.componentConfig.deploy && context.componentConfig.deploy.when ? context.componentConfig.deploy.when : undefined; // otherwise auto deploy if env is not prod. If its prod, deploy automatically if stage is disabled
|
|
36
46
|
|
|
37
|
-
var
|
|
38
|
-
: ((_a = context.componentConfig.env) === null || _a === void 0 ? void 0 : _a.stage) === false ?
|
|
39
|
-
:
|
|
47
|
+
var whenDeployDefault = context.environment.envType !== "prod" ? "auto" // is not stage, auto deploy
|
|
48
|
+
: ((_a = context.componentConfig.env) === null || _a === void 0 ? void 0 : _a.stage) === false ? "auto" // is prod, but no staging, auto deploy
|
|
49
|
+
: "manual"; // manually deploy
|
|
40
50
|
|
|
51
|
+
var whenDeploy = whenDeployDefined ? whenDeployDefined : whenDeployDefault;
|
|
41
52
|
return {
|
|
42
53
|
name: exports.DEPLOY_JOB_NAME,
|
|
43
54
|
envMode: "stagePerEnv",
|
|
55
|
+
needsOtherComponent: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
|
|
56
|
+
return {
|
|
57
|
+
componentName: c,
|
|
58
|
+
job: exports.DEPLOY_JOB_NAME,
|
|
59
|
+
artifacts: false
|
|
60
|
+
};
|
|
61
|
+
})) !== null && _c !== void 0 ? _c : undefined : undefined,
|
|
44
62
|
// we don't want to deploy when there is a broken test
|
|
45
63
|
needsStages: [{
|
|
46
64
|
stage: "build",
|
|
47
|
-
artifacts: false
|
|
65
|
+
artifacts: hasDocker ? false : true
|
|
48
66
|
}, {
|
|
49
67
|
stage: "test",
|
|
50
68
|
artifacts: false
|
|
51
69
|
}],
|
|
52
|
-
rules: [
|
|
70
|
+
rules: [whenDeploy === "auto" ? {
|
|
53
71
|
when: "on_success"
|
|
54
72
|
} : {
|
|
55
73
|
when: "manual"
|
|
56
74
|
}],
|
|
75
|
+
allow_failure: whenDeploy === "manual" ? true : false,
|
|
57
76
|
stage: "deploy",
|
|
58
|
-
variables: __assign({}, DEPLOY_RUNNER_VARIABLES),
|
|
59
|
-
environment: __assign(__assign({}, environment), {
|
|
77
|
+
variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars),
|
|
78
|
+
environment: __assign(__assign({}, environment), isStoppable ? {
|
|
60
79
|
on_stop: exports.STOP_JOB_NAME,
|
|
61
80
|
auto_stop_in: autoStop
|
|
62
|
-
})
|
|
81
|
+
} : {})
|
|
63
82
|
};
|
|
64
83
|
};
|
|
65
84
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
e = {
|
|
15
|
+
error: error
|
|
16
|
+
};
|
|
17
|
+
} finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
} finally {
|
|
21
|
+
if (e) throw e.error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
exports.createCustomDeployJobs = void 0;
|
|
40
|
+
|
|
41
|
+
var lodash_1 = require("lodash");
|
|
42
|
+
|
|
43
|
+
var base_1 = require("../base");
|
|
44
|
+
|
|
45
|
+
var types_1 = require("../types");
|
|
46
|
+
|
|
47
|
+
var createCustomDeployJobs = function (context) {
|
|
48
|
+
var deployConfig = context.componentConfig.deploy;
|
|
49
|
+
|
|
50
|
+
if (deployConfig === false) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "custom")) {
|
|
55
|
+
// should not happen
|
|
56
|
+
throw new Error("deploy config is not custom");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
|
|
60
|
+
return [(0, lodash_1.merge)({}, baseDeploymentJob, {
|
|
61
|
+
script: __spreadArray(["cd ".concat(context.componentConfig.dir)], __read(deployConfig.script), false)
|
|
62
|
+
})];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.createCustomDeployJobs = createCustomDeployJobs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./deployJob";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
Object.defineProperty(o, k2, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function () {
|
|
8
|
+
return m[k];
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
} : function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.__esModule = true;
|
|
21
|
+
|
|
22
|
+
__exportStar(require("./deployJob"), exports);
|
package/dist/deploy/index.js
CHANGED
|
@@ -20,6 +20,8 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
|
20
20
|
exports.__esModule = true;
|
|
21
21
|
exports.DEPLOY_TYPES = void 0;
|
|
22
22
|
|
|
23
|
+
var custom_1 = require("./custom");
|
|
24
|
+
|
|
23
25
|
var kubernetes_1 = require("./kubernetes");
|
|
24
26
|
|
|
25
27
|
__exportStar(require("./kubernetes"), exports);
|
|
@@ -34,5 +36,11 @@ exports.DEPLOY_TYPES = {
|
|
|
34
36
|
defaults: function () {
|
|
35
37
|
return {};
|
|
36
38
|
}
|
|
39
|
+
},
|
|
40
|
+
custom: {
|
|
41
|
+
jobs: custom_1.createCustomDeployJobs,
|
|
42
|
+
defaults: function () {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
};
|
|
@@ -70,6 +70,8 @@ var cloudsql_1 = require("./cloudsql");
|
|
|
70
70
|
|
|
71
71
|
var mongodb_1 = require("./mongodb");
|
|
72
72
|
|
|
73
|
+
var processSecretsAsFiles_1 = require("./processSecretsAsFiles");
|
|
74
|
+
|
|
73
75
|
var createKubernetesDeployJobs = function (context) {
|
|
74
76
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
75
77
|
|
|
@@ -135,7 +137,7 @@ var createKubernetesDeployJobs = function (context) {
|
|
|
135
137
|
env: env
|
|
136
138
|
}, ((_l = (_k = deployConfig.values) === null || _k === void 0 ? void 0 : _k.cloudsql) === null || _l === void 0 ? void 0 : _l.enabled) ? (0, cloudsql_1.createCloudsqlBaseConfig)(context) : {}), ((_o = (_m = deployConfig.values) === null || _m === void 0 ? void 0 : _m.mongodb) === null || _o === void 0 ? void 0 : _o.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
|
|
137
139
|
|
|
138
|
-
var kubeValues = (0, utils_1.mergeWithMergingArrays)(defaultKubeValues, deployConfig.values);
|
|
140
|
+
var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, deployConfig.values));
|
|
139
141
|
var kubernetesEnvironment = {
|
|
140
142
|
namespace: context.environment.envVars.KUBE_NAMESPACE
|
|
141
143
|
};
|