@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-refactor-env-context-9e652b63
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/bin/catladder-gitlab.js +1 -1
- package/dist/build/base/createBuildJob.d.ts +2 -2
- package/dist/build/base/getBuildInfo.d.ts +1 -1
- package/dist/build/docker.d.ts +44 -6
- package/dist/build/docker.js +45 -19
- package/dist/build/index.d.ts +6 -5
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/index.d.ts +1 -1
- package/dist/build/node/meteor.d.ts +1 -1
- package/dist/build/node/meteor.js +6 -0
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +3 -0
- package/dist/build/node/yarn.d.ts +1 -1
- package/dist/build/node/yarn.js +13 -1
- package/dist/build/types.d.ts +10 -0
- package/dist/bundles/catladder-gitlab/index.js +32457 -0
- package/dist/catladder-gitlab.js +1 -2
- package/dist/config/configruedEnvs.d.ts +1 -1
- package/dist/config/readConfig.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context/getEnvConfig.d.ts +9 -0
- package/dist/context/getEnvConfig.js +26 -0
- package/dist/context/getEnvType.d.ts +4 -0
- package/dist/context/getEnvType.js +18 -0
- package/dist/context/getEnvironment.d.ts +3 -0
- package/dist/context/getEnvironment.js +187 -0
- package/dist/context/getEnvironmentContext.d.ts +4 -0
- package/dist/context/getEnvironmentContext.js +36 -0
- package/dist/context/getEnvironmentVariables.d.ts +10 -0
- package/dist/context/getEnvironmentVariables.js +322 -0
- package/dist/context/getLabels.d.ts +8 -0
- package/dist/context/getLabels.js +49 -0
- package/dist/context/index.d.ts +5 -6
- package/dist/context/index.js +176 -181
- package/dist/context/resolveReferences.d.ts +1 -3
- package/dist/context/resolveReferences.js +275 -26
- package/dist/context/resolveReferences.test.js +332 -81
- package/dist/defaults/index.d.ts +1 -1
- package/dist/deploy/base.d.ts +4 -2
- package/dist/deploy/base.js +37 -17
- package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
- package/dist/deploy/cloudRun/deployJob.js +139 -0
- package/dist/deploy/cloudRun/index.d.ts +9 -0
- package/dist/deploy/cloudRun/index.js +56 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +14 -0
- package/dist/deploy/cloudSql/index.d.ts +8 -0
- package/dist/deploy/cloudSql/index.js +30 -0
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +4 -1
- package/dist/deploy/custom/index.d.ts +2 -1
- package/dist/deploy/custom/index.js +15 -18
- package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
- package/dist/deploy/dockerTag/deployJob.js +33 -0
- package/dist/deploy/dockerTag/index.d.ts +2 -0
- package/dist/deploy/dockerTag/index.js +19 -0
- package/dist/deploy/index.d.ts +12 -8
- package/dist/deploy/index.js +27 -14
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
- package/dist/deploy/kubernetes/additionalSecretKeys.js +33 -0
- package/dist/deploy/kubernetes/cloudsql.d.ts +1 -1
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +13 -66
- package/dist/deploy/kubernetes/index.d.ts +2 -1
- package/dist/deploy/kubernetes/index.js +45 -16
- package/dist/deploy/kubernetes/kubeEnv.d.ts +10 -0
- package/dist/deploy/kubernetes/kubeEnv.js +90 -0
- package/dist/deploy/kubernetes/kubeValues.d.ts +90 -0
- package/dist/deploy/kubernetes/kubeValues.js +96 -0
- package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
- package/dist/deploy/kubernetes/mongodb.js +118 -8
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +21 -21
- package/dist/deploy/types/base.d.ts +15 -0
- package/dist/deploy/types/base.js +3 -0
- package/dist/deploy/types/custom.d.ts +27 -0
- package/dist/deploy/types/custom.js +3 -0
- package/dist/deploy/types/dockerTag.d.ts +10 -0
- package/dist/deploy/types/dockerTag.js +3 -0
- package/dist/deploy/types/googleCloudRun.d.ts +39 -0
- package/dist/deploy/types/googleCloudRun.js +3 -0
- package/dist/deploy/types/index.d.ts +24 -0
- package/dist/deploy/types/index.js +41 -0
- package/dist/deploy/{types.d.ts → types/kubernetes.d.ts} +128 -36
- package/dist/deploy/types/kubernetes.js +3 -0
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/deploy/utils.js +4 -0
- package/dist/pipeline/createChildPipeline.d.ts +2 -2
- package/dist/pipeline/createChildPipeline.js +3 -3
- package/dist/pipeline/createJobs.d.ts +2 -2
- package/dist/pipeline/createJobs.js +63 -25
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +3 -2
- package/dist/pipeline/gitlab/makeGitlabJob.js +2 -1
- package/dist/pipeline/packageManager.d.ts +1 -1
- package/dist/rules/index.d.ts +1 -1
- package/dist/runner/index.d.ts +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +7 -6
- package/dist/types/config.js +1 -1
- package/dist/types/context.d.ts +10 -2
- package/dist/types/environmentContext.d.ts +22 -0
- package/dist/types/environmentContext.js +3 -0
- package/dist/types/gitlab-types.d.ts +1 -1
- package/dist/types/jobs.d.ts +8 -3
- package/dist/types/jobs.js +1 -1
- package/dist/types/pipeline.d.ts +1 -1
- package/package.json +15 -11
- package/scripts/bundle +2 -0
- package/src/build/base/createBuildJob.ts +3 -2
- package/src/build/base/getBuildInfo.ts +1 -1
- package/src/build/docker.ts +47 -29
- package/src/build/index.ts +8 -5
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +2 -2
- package/src/build/node/index.ts +1 -1
- package/src/build/node/meteor.ts +8 -2
- package/src/build/node/testJob.ts +4 -2
- package/src/build/node/yarn.ts +21 -10
- package/src/build/tests/storybook.test.ts +1 -1
- package/src/build/types.ts +13 -1
- package/src/catladder-gitlab.ts +4 -2
- package/src/config/configruedEnvs.test.ts +2 -2
- package/src/config/configruedEnvs.ts +5 -4
- package/src/config/readConfig.ts +1 -1
- package/src/context/getEnvConfig.ts +21 -0
- package/src/context/getEnvType.ts +17 -0
- package/src/context/getEnvironment.ts +40 -0
- package/src/context/getEnvironmentContext.ts +57 -0
- package/src/context/getEnvironmentVariables.ts +152 -0
- package/src/context/getLabels.ts +20 -0
- package/src/context/index.ts +25 -191
- package/src/context/resolveReferences.test.ts +15 -15
- package/src/context/resolveReferences.ts +37 -30
- package/src/defaults/index.ts +1 -1
- package/src/deploy/base.ts +43 -19
- package/src/deploy/cloudRun/deployJob.ts +104 -0
- package/src/deploy/cloudRun/index.ts +48 -0
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
- package/src/deploy/cloudSql/index.ts +16 -0
- package/src/deploy/custom/deployJob.ts +10 -3
- package/src/deploy/custom/index.ts +9 -1
- package/src/deploy/dockerTag/deployJob.ts +31 -0
- package/src/deploy/dockerTag/index.ts +9 -0
- package/src/deploy/index.ts +26 -17
- package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
- package/src/deploy/kubernetes/cloudsql.ts +2 -1
- package/src/deploy/kubernetes/deployJob.ts +19 -77
- package/src/deploy/kubernetes/index.ts +42 -1
- package/src/deploy/kubernetes/kubeEnv.ts +48 -0
- package/src/deploy/kubernetes/kubeValues.ts +82 -0
- package/src/deploy/kubernetes/mongodb.ts +104 -7
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
- package/src/deploy/types/base.ts +17 -0
- package/src/deploy/types/custom.ts +24 -0
- package/src/deploy/types/dockerTag.ts +12 -0
- package/src/deploy/types/googleCloudRun.ts +79 -0
- package/src/deploy/types/index.ts +28 -0
- package/src/deploy/types/kubernetes.ts +281 -0
- package/src/deploy/utils.ts +6 -2
- package/src/pipeline/createChildPipeline.test.ts +1 -1
- package/src/pipeline/createChildPipeline.ts +4 -4
- package/src/pipeline/createJobs.ts +32 -21
- package/src/pipeline/gitlab/makeGitlabJob.ts +3 -2
- package/src/pipeline/packageManager.ts +1 -1
- package/src/rules/index.ts +1 -1
- package/src/runner/index.ts +2 -1
- package/src/types/config.ts +8 -6
- package/src/types/context.ts +14 -2
- package/src/types/environmentContext.ts +26 -0
- package/src/types/gitlab-types.ts +1 -1
- package/src/types/jobs.ts +9 -2
- package/src/types/pipeline.ts +1 -1
- package/tsconfig.json +2 -0
- package/dist/deploy/types.js +0 -16
- package/src/deploy/types.ts +0 -189
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DeployTypeDefinition } from "..";
|
|
2
|
+
export declare const KUBERNETES_DEPLOY_TYPE: DeployTypeDefinition<"kubernetes">;
|
|
@@ -1,22 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
3
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
"default": mod
|
|
6
|
+
};
|
|
18
7
|
};
|
|
19
8
|
|
|
20
9
|
exports.__esModule = true;
|
|
10
|
+
exports.KUBERNETES_DEPLOY_TYPE = void 0;
|
|
21
11
|
|
|
22
|
-
|
|
12
|
+
var slugify_1 = __importDefault(require("slugify"));
|
|
13
|
+
|
|
14
|
+
var __1 = require("..");
|
|
15
|
+
|
|
16
|
+
var additionalSecretKeys_1 = require("./additionalSecretKeys");
|
|
17
|
+
|
|
18
|
+
var deployJob_1 = require("./deployJob");
|
|
19
|
+
|
|
20
|
+
exports.KUBERNETES_DEPLOY_TYPE = {
|
|
21
|
+
jobs: deployJob_1.createKubernetesDeployJobs,
|
|
22
|
+
defaults: function () {
|
|
23
|
+
return {};
|
|
24
|
+
},
|
|
25
|
+
additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys,
|
|
26
|
+
getAdditionalEnvVars: function (_a) {
|
|
27
|
+
var _b;
|
|
28
|
+
|
|
29
|
+
var componentName = _a.componentName,
|
|
30
|
+
fullConfig = _a.fullConfig,
|
|
31
|
+
deployConfigRaw = _a.deployConfigRaw,
|
|
32
|
+
env = _a.env,
|
|
33
|
+
envType = _a.envType,
|
|
34
|
+
commitInfo = _a.commitInfo;
|
|
35
|
+
var KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
|
|
36
|
+
var KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
|
|
37
|
+
var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
|
|
38
|
+
var componentSlug = (0, slugify_1["default"])(componentName);
|
|
39
|
+
var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
|
|
40
|
+
var domainCanonical = deployConfigRaw && ((_b = deployConfigRaw.cluster) === null || _b === void 0 ? void 0 : _b.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
|
|
41
|
+
fullConfig.domainCanonical || "panter.cloud";
|
|
42
|
+
var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
KUBE_NAMESPACE: KUBE_NAMESPACE,
|
|
46
|
+
KUBE_APP_NAME: KUBE_APP_NAME,
|
|
47
|
+
KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
|
|
48
|
+
HOST_CANONICAL: HOST_CANONICAL
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* separate by secrets and public.
|
|
4
|
+
* we evalulate the actual values later, but want to store the secrets in kubernetes secrets
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export declare const createKubeEnv: (context: Context) => {
|
|
8
|
+
secret: Record<string, string>;
|
|
9
|
+
public: Record<string, string>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var __read = this && this.__read || function (o, n) {
|
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
+
if (!m) return o;
|
|
20
|
+
var i = m.call(o),
|
|
21
|
+
r,
|
|
22
|
+
ar = [],
|
|
23
|
+
e;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
e = {
|
|
29
|
+
error: error
|
|
30
|
+
};
|
|
31
|
+
} finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
} finally {
|
|
35
|
+
if (e) throw e.error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.__esModule = true;
|
|
43
|
+
exports.createKubeEnv = void 0;
|
|
44
|
+
|
|
45
|
+
var types_1 = require("../types");
|
|
46
|
+
|
|
47
|
+
var shouldGoIntoSecrets = function (key, value) {
|
|
48
|
+
var _a;
|
|
49
|
+
|
|
50
|
+
if ((_a = String(value)) === null || _a === void 0 ? void 0 : _a.includes("$CL_")) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* separate by secrets and public.
|
|
58
|
+
* we evalulate the actual values later, but want to store the secrets in kubernetes secrets
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
var createKubeEnv = function (context) {
|
|
63
|
+
if (!(0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
|
|
64
|
+
// should not happen
|
|
65
|
+
throw new Error("deploy config is not kubernetes");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var allEnvVars = context.environment.envVars;
|
|
69
|
+
var env = Object.entries(allEnvVars).reduce(function (acc, _a) {
|
|
70
|
+
var _b, _c;
|
|
71
|
+
|
|
72
|
+
var _d = __read(_a, 2),
|
|
73
|
+
key = _d[0],
|
|
74
|
+
value = _d[1];
|
|
75
|
+
|
|
76
|
+
if (shouldGoIntoSecrets(key, value)) {
|
|
77
|
+
acc.secret = __assign(__assign({}, acc.secret), (_b = {}, _b[key] = value, _b));
|
|
78
|
+
return acc;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
acc.public = __assign(__assign({}, acc.public), (_c = {}, _c[key] = value, _c));
|
|
82
|
+
return acc;
|
|
83
|
+
}, {
|
|
84
|
+
secret: {},
|
|
85
|
+
public: {}
|
|
86
|
+
});
|
|
87
|
+
return env;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
exports.createKubeEnv = createKubeEnv;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Context } from "../../types/context";
|
|
2
|
+
export declare const createKubeValues: (context: Context) => never[] | ({
|
|
3
|
+
env: {
|
|
4
|
+
secret: Record<string, string>;
|
|
5
|
+
public: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
application: false | import("../types/base").AllowUnknownProps<{
|
|
8
|
+
enabled?: boolean | undefined;
|
|
9
|
+
redirects?: import("../types/base").AllowUnknownProps<{
|
|
10
|
+
host: string;
|
|
11
|
+
}>[] | undefined;
|
|
12
|
+
hostAliases?: string[] | undefined;
|
|
13
|
+
replicas?: number | undefined;
|
|
14
|
+
autoscale?: import("../types").KubernetesAutoscale | undefined;
|
|
15
|
+
updateStrategy?: import("../types").KubernetesUpdateStrategy | undefined;
|
|
16
|
+
resources?: import("../types").KubernetesResourcesDef | undefined;
|
|
17
|
+
healthRoute?: string | undefined;
|
|
18
|
+
startupProbe?: {
|
|
19
|
+
httpGet?: {
|
|
20
|
+
path?: string | undefined;
|
|
21
|
+
port?: number | undefined;
|
|
22
|
+
httpHeaders?: {
|
|
23
|
+
name: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[] | undefined;
|
|
26
|
+
failureThreshold?: number | undefined;
|
|
27
|
+
timeoutSeconds?: number | undefined;
|
|
28
|
+
periodSeconds?: number | undefined;
|
|
29
|
+
successThreshold?: number | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
readinessProbe?: {
|
|
33
|
+
httpGet?: {
|
|
34
|
+
path?: string | undefined;
|
|
35
|
+
port?: number | undefined;
|
|
36
|
+
httpHeaders?: {
|
|
37
|
+
name: string;
|
|
38
|
+
value: string;
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
failureThreshold?: number | undefined;
|
|
41
|
+
timeoutSeconds?: number | undefined;
|
|
42
|
+
periodSeconds?: number | undefined;
|
|
43
|
+
successThreshold?: number | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | undefined;
|
|
46
|
+
livenessProbe?: {
|
|
47
|
+
httpGet?: {
|
|
48
|
+
path?: string | undefined;
|
|
49
|
+
port?: number | undefined;
|
|
50
|
+
httpHeaders?: {
|
|
51
|
+
name: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}[] | undefined;
|
|
54
|
+
failureThreshold?: number | undefined;
|
|
55
|
+
timeoutSeconds?: number | undefined;
|
|
56
|
+
periodSeconds?: number | undefined;
|
|
57
|
+
successThreshold?: number | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
worker?: import("../types").KubernetesWorkerDef | undefined;
|
|
61
|
+
}> | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
cloudsql?: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
instanceId?: string | undefined;
|
|
67
|
+
projectId?: string | undefined;
|
|
68
|
+
region?: string | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
mongodb?: import("../types").DeployConfigMongodb | undefined;
|
|
71
|
+
mailhog?: {
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
} | undefined;
|
|
74
|
+
jobs?: Record<string, import("../types/base").AllowUnknownProps<{
|
|
75
|
+
command: string;
|
|
76
|
+
hook?: string | undefined;
|
|
77
|
+
}>> | undefined;
|
|
78
|
+
cronjobs?: Record<string, import("../types/base").AllowUnknownProps<{
|
|
79
|
+
schedule: string;
|
|
80
|
+
command: string;
|
|
81
|
+
concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
|
|
82
|
+
}>> | undefined;
|
|
83
|
+
secretsFromOtherComponent?: {
|
|
84
|
+
[envVar: string]: string;
|
|
85
|
+
} | undefined;
|
|
86
|
+
mapServiceUrlToEnv?: {
|
|
87
|
+
[envVar: string]: string;
|
|
88
|
+
} | undefined;
|
|
89
|
+
secretsAsFile?: string[] | undefined;
|
|
90
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
7
|
+
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.__esModule = true;
|
|
15
|
+
exports.createKubeValues = void 0;
|
|
16
|
+
|
|
17
|
+
var lodash_1 = require("lodash");
|
|
18
|
+
|
|
19
|
+
var utils_1 = require("../../utils");
|
|
20
|
+
|
|
21
|
+
var cloudSql_1 = require("../cloudSql");
|
|
22
|
+
|
|
23
|
+
var types_1 = require("../types");
|
|
24
|
+
|
|
25
|
+
var cloudsql_1 = require("./cloudsql");
|
|
26
|
+
|
|
27
|
+
var kubeEnv_1 = require("./kubeEnv");
|
|
28
|
+
|
|
29
|
+
var mongodb_1 = require("./mongodb");
|
|
30
|
+
|
|
31
|
+
var processSecretsAsFiles_1 = require("./processSecretsAsFiles");
|
|
32
|
+
|
|
33
|
+
var createAppConfig = function (context, application) {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
|
|
36
|
+
if (application === false) {
|
|
37
|
+
return {
|
|
38
|
+
enabled: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (0, utils_1.mergeWithMergingArrays)({
|
|
43
|
+
host: context.environment.host,
|
|
44
|
+
command: context.componentConfig.build.startCommand,
|
|
45
|
+
livenessProbe: {
|
|
46
|
+
httpGet: {
|
|
47
|
+
path: (_a = application === null || application === void 0 ? void 0 : application.healthRoute) !== null && _a !== void 0 ? _a : "__health"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
readinessProbe: {
|
|
51
|
+
httpGet: {
|
|
52
|
+
path: (_b = application === null || application === void 0 ? void 0 : application.healthRoute) !== null && _b !== void 0 ? _b : "__health"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
startupProbe: {
|
|
56
|
+
httpGet: {
|
|
57
|
+
path: (_c = application === null || application === void 0 ? void 0 : application.healthRoute) !== null && _c !== void 0 ? _c : "__health"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, // default
|
|
61
|
+
application // merge rest in
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var createKubeValues = function (context) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
|
|
68
|
+
var deployConfig = context.componentConfig.deploy;
|
|
69
|
+
|
|
70
|
+
if (deployConfig === false) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "kubernetes")) {
|
|
75
|
+
// should not happen
|
|
76
|
+
throw new Error("deploy config is not kubernetes");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var values = deployConfig.values; // we remove the application config because it can be just the value `false` which is a convenience feature, but not supported in the helm chart
|
|
80
|
+
// we only merge the rest of the values in
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
82
|
+
|
|
83
|
+
var _c = values !== null && values !== void 0 ? values : {},
|
|
84
|
+
application = _c.application,
|
|
85
|
+
rest = __rest(_c, ["application"]);
|
|
86
|
+
|
|
87
|
+
var env = (0, kubeEnv_1.createKubeEnv)(context);
|
|
88
|
+
var defaultKubeValues = (0, lodash_1.merge)({
|
|
89
|
+
env: env,
|
|
90
|
+
application: createAppConfig(context, application)
|
|
91
|
+
}, (0, cloudSql_1.hasCloudSQL)(context) ? (0, cloudsql_1.createCloudsqlBaseConfig)(context) : {}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
|
|
92
|
+
var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, rest));
|
|
93
|
+
return kubeValues;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.createKubeValues = createKubeValues;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
import { Context } from "../..";
|
|
1
|
+
import type { Context } from "../..";
|
|
2
2
|
export declare const createMongodbBaseConfig: (context: Context) => {
|
|
3
3
|
mongodb: {
|
|
4
4
|
enabled: boolean;
|
|
5
|
+
auth: {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
rootPassword: string;
|
|
8
|
+
replicaSetKey: string;
|
|
9
|
+
};
|
|
10
|
+
persistence: {
|
|
11
|
+
storageClass: string;
|
|
12
|
+
};
|
|
5
13
|
backup: {
|
|
6
14
|
enabled: boolean;
|
|
15
|
+
hostToBackup: string;
|
|
16
|
+
pvcToBackup: string;
|
|
17
|
+
image: string;
|
|
18
|
+
schedule: string;
|
|
19
|
+
volumeSnapshotClass: string;
|
|
7
20
|
};
|
|
8
21
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
env: {
|
|
23
|
+
secret: {
|
|
24
|
+
MONGO_OPLOG_URL?: string | undefined;
|
|
25
|
+
MONGO_URL: string;
|
|
13
26
|
};
|
|
14
27
|
};
|
|
15
28
|
};
|
|
@@ -1,21 +1,131 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
3
17
|
exports.__esModule = true;
|
|
4
18
|
exports.createMongodbBaseConfig = void 0;
|
|
5
19
|
|
|
20
|
+
var lodash_1 = require("lodash");
|
|
21
|
+
|
|
22
|
+
var __1 = require("../..");
|
|
23
|
+
|
|
24
|
+
var getCredentialString = function (context) {
|
|
25
|
+
return "root:$".concat((0, __1.getSecretVarNameForContext)(context, "MONGODB_ROOT_PASSWORD"), "@");
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var getMongodbHost = function (context, name) {
|
|
29
|
+
var namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
30
|
+
return "".concat(name, ".").concat(namespace, ".svc.cluster.local:27017");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var getMongodbStandaloneHost = function (context) {
|
|
34
|
+
var fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
35
|
+
return getMongodbHost(context, "".concat(fullAppname, "-mongodb"));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var getMongodbReplicasetHost = function (context, index) {
|
|
39
|
+
var fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
40
|
+
return getMongodbHost(context, "".concat(fullAppname, "-mongodb-").concat(index, ".").concat(fullAppname, "-mongodb-headless"));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var createMongodbUrl = function (context, dbName) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
|
|
46
|
+
if (!(0, __1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
|
|
47
|
+
throw new Error("can only createMongodbUrl on supported deploys");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var mongodbConfig = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb;
|
|
51
|
+
var queryParams = undefined;
|
|
52
|
+
var hosts = "";
|
|
53
|
+
|
|
54
|
+
if ((mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset") {
|
|
55
|
+
hosts = (0, lodash_1.range)(0, (_b = mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.replicaCount) !== null && _b !== void 0 ? _b : 2).map(function (i) {
|
|
56
|
+
return getMongodbReplicasetHost(context, i);
|
|
57
|
+
}).join(",");
|
|
58
|
+
queryParams = "replicaSet=rs0&authSource=admin";
|
|
59
|
+
} else {
|
|
60
|
+
hosts = getMongodbStandaloneHost(context);
|
|
61
|
+
queryParams = "authSource=admin";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return "mongodb://".concat(getCredentialString(context)).concat(hosts, "/").concat(dbName).concat(queryParams ? "?".concat(queryParams) : "");
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var createMongoBackupDefaultConfig = function (context) {
|
|
68
|
+
var _a;
|
|
69
|
+
|
|
70
|
+
if (!(0, __1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
|
|
71
|
+
throw new Error("can only create mongodb base config on supported deploys");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var mongodbConfig = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb;
|
|
75
|
+
var fullAppName = context.environment.envVars.KUBE_APP_NAME;
|
|
76
|
+
var backupEnabled = ["prod", "stage"].includes(context.environment.envType);
|
|
77
|
+
var hostToBackup;
|
|
78
|
+
var pvcToBackup;
|
|
79
|
+
|
|
80
|
+
if ((mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset") {
|
|
81
|
+
// bit quirky, we need to specify the host and its volume
|
|
82
|
+
// on replicaset its probably best to not use the first one, whcih usually starts as master, so we take the second (last one would also be ok)
|
|
83
|
+
var backupHostIndex = (mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset" && mongodbConfig.replicaCount && mongodbConfig.replicaCount > 1 ? 1 : 0;
|
|
84
|
+
hostToBackup = getMongodbReplicasetHost(context, backupHostIndex);
|
|
85
|
+
pvcToBackup = "datadir-".concat(fullAppName, "-mongodb-").concat(backupHostIndex);
|
|
86
|
+
} else {
|
|
87
|
+
hostToBackup = getMongodbStandaloneHost(context);
|
|
88
|
+
pvcToBackup = "".concat(fullAppName, "-mongodb");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
enabled: backupEnabled,
|
|
93
|
+
hostToBackup: hostToBackup,
|
|
94
|
+
pvcToBackup: pvcToBackup,
|
|
95
|
+
image: "mrelite/kubectlmongoshell:v1.0",
|
|
96
|
+
schedule: "0 4 * * *",
|
|
97
|
+
volumeSnapshotClass: "snapshotclass"
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
6
101
|
var createMongodbBaseConfig = function (context) {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
|
|
104
|
+
if (!(0, __1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
|
|
105
|
+
throw new Error("can only create mongodb base config on supported deploys");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var mongodbConfig = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb;
|
|
7
109
|
return {
|
|
8
110
|
mongodb: {
|
|
9
111
|
enabled: true,
|
|
10
|
-
|
|
11
|
-
enabled:
|
|
12
|
-
|
|
112
|
+
auth: {
|
|
113
|
+
enabled: true,
|
|
114
|
+
rootPassword: "$" + (0, __1.getSecretVarNameForContext)(context, "MONGODB_ROOT_PASSWORD"),
|
|
115
|
+
replicaSetKey: "$" + (0, __1.getSecretVarNameForContext)(context, "MONGODB_REPLICASET_KEY")
|
|
116
|
+
},
|
|
117
|
+
persistence: {
|
|
118
|
+
storageClass: "standard-rwo"
|
|
119
|
+
},
|
|
120
|
+
backup: createMongoBackupDefaultConfig(context)
|
|
13
121
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
122
|
+
env: {
|
|
123
|
+
secret: __assign({
|
|
124
|
+
MONGO_URL: createMongodbUrl(context, (_b = mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.dbName) !== null && _b !== void 0 ? _b : "app")
|
|
125
|
+
}, (mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset" ? {
|
|
126
|
+
MONGO_OPLOG_URL: createMongodbUrl(context, "local")
|
|
127
|
+
} // oplog only works with replicasets
|
|
128
|
+
: {})
|
|
19
129
|
}
|
|
20
130
|
};
|
|
21
131
|
};
|
|
@@ -9,36 +9,29 @@ export declare const processSecretsAsFiles: <T extends {
|
|
|
9
9
|
projectId?: string | undefined;
|
|
10
10
|
region?: string | undefined;
|
|
11
11
|
} | undefined;
|
|
12
|
-
mongodb?: (
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
} & Record<string, unknown>) | undefined;
|
|
12
|
+
mongodb?: import("../types").DeployConfigMongodb | undefined;
|
|
15
13
|
mailhog?: {
|
|
16
14
|
enabled: boolean;
|
|
17
15
|
} | undefined;
|
|
18
|
-
jobs?: Record<string, {
|
|
16
|
+
jobs?: Record<string, import("../types/base").AllowUnknownProps<{
|
|
19
17
|
command: string;
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
hook?: string | undefined;
|
|
19
|
+
}>> | undefined;
|
|
20
|
+
cronjobs?: Record<string, import("../types/base").AllowUnknownProps<{
|
|
22
21
|
schedule: string;
|
|
23
22
|
command: string;
|
|
24
23
|
concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
|
|
25
|
-
}
|
|
26
|
-
application?: ({
|
|
27
|
-
|
|
24
|
+
}>> | undefined;
|
|
25
|
+
application?: false | import("../types/base").AllowUnknownProps<{
|
|
26
|
+
enabled?: boolean | undefined;
|
|
27
|
+
redirects?: import("../types/base").AllowUnknownProps<{
|
|
28
28
|
host: string;
|
|
29
|
-
}
|
|
29
|
+
}>[] | undefined;
|
|
30
|
+
hostAliases?: string[] | undefined;
|
|
30
31
|
replicas?: number | undefined;
|
|
31
32
|
autoscale?: import("../types").KubernetesAutoscale | undefined;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
cpu?: string | undefined;
|
|
35
|
-
memory?: string | undefined;
|
|
36
|
-
} | undefined;
|
|
37
|
-
requests?: {
|
|
38
|
-
cpu?: string | undefined;
|
|
39
|
-
memory?: string | undefined;
|
|
40
|
-
} | undefined;
|
|
41
|
-
} | undefined;
|
|
33
|
+
updateStrategy?: import("../types").KubernetesUpdateStrategy | undefined;
|
|
34
|
+
resources?: import("../types").KubernetesResourcesDef | undefined;
|
|
42
35
|
healthRoute?: string | undefined;
|
|
43
36
|
startupProbe?: {
|
|
44
37
|
httpGet?: {
|
|
@@ -82,6 +75,13 @@ export declare const processSecretsAsFiles: <T extends {
|
|
|
82
75
|
successThreshold?: number | undefined;
|
|
83
76
|
} | undefined;
|
|
84
77
|
} | undefined;
|
|
85
|
-
|
|
78
|
+
worker?: import("../types").KubernetesWorkerDef | undefined;
|
|
79
|
+
}> | undefined;
|
|
80
|
+
secretsFromOtherComponent?: {
|
|
81
|
+
[envVar: string]: string;
|
|
82
|
+
} | undefined;
|
|
83
|
+
mapServiceUrlToEnv?: {
|
|
84
|
+
[envVar: string]: string;
|
|
85
|
+
} | undefined;
|
|
86
86
|
secretsAsFile?: string[] | undefined;
|
|
87
87
|
} & Record<string, unknown>>(values: T) => T;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type DeployConfigBase = {
|
|
2
|
+
/**
|
|
3
|
+
* whether to deploy automatically or manual. If not defined, these rules apply:
|
|
4
|
+
* - prod: manual
|
|
5
|
+
* - all other envs: auto
|
|
6
|
+
*/
|
|
7
|
+
when?: "manual" | "auto";
|
|
8
|
+
/**
|
|
9
|
+
* EXPERIMENTAL
|
|
10
|
+
* wait for other components to deploy first, before doing this deployment
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
waitFor?: string[];
|
|
14
|
+
};
|
|
15
|
+
export declare type AllowUnknownProps<T extends Record<string, unknown>> = T & Record<string, unknown>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DeployConfigBase } from "./base";
|
|
2
|
+
export declare type DeployConfigCustom = {
|
|
3
|
+
/**
|
|
4
|
+
* custom deploy types allow you to specify custom commands to deploy your app
|
|
5
|
+
*/
|
|
6
|
+
type: "custom";
|
|
7
|
+
/**
|
|
8
|
+
* whether the deploy script requires a docker image to be built
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
requiresDocker: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* whether your custom script requires yarn install
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
requiresYarnInstall?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* your custom script
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
script: string[];
|
|
22
|
+
/**
|
|
23
|
+
* script to run to stop the environment
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
stopScript?: string[];
|
|
27
|
+
} & DeployConfigBase;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DeployConfigBase } from "./base";
|
|
2
|
+
export declare type DeployConfigDockerTag = {
|
|
3
|
+
/**
|
|
4
|
+
* adds a custom tag on the repo to deploy it.
|
|
5
|
+
*
|
|
6
|
+
* only used in veloplus atm, generally not recommended to use
|
|
7
|
+
*/
|
|
8
|
+
type: "dockerTag";
|
|
9
|
+
tag: string;
|
|
10
|
+
} & DeployConfigBase;
|