@catladder/cli 5.2.0 → 5.3.0
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/apps/cli/src/commands/project/commandPortForward.js +1 -1
- package/dist/apps/cli/src/commands/project/commandPortForward.js.map +1 -1
- package/dist/apps/cli/src/commands/project/secrets/scope.js +25 -2
- package/dist/apps/cli/src/commands/project/secrets/scope.js.map +1 -1
- package/dist/apps/cli/src/config/getProjectConfig.js +4 -1
- package/dist/apps/cli/src/config/getProjectConfig.js.map +1 -1
- package/dist/apps/cli/src/secrets/github.js +4 -2
- package/dist/apps/cli/src/secrets/github.js.map +1 -1
- package/dist/bundles/catenv/index.js +390 -106
- package/dist/bundles/cli/index.js +420 -111
- package/dist/bundles/skills/catladder-config/SKILL.md +34 -2
- package/dist/bundles/skills/catladder-deploys/SKILL.md +5 -0
- package/dist/bundles/skills/catladder-pipelines/SKILL.md +10 -1
- package/dist/bundles/skills/catladder-secrets/SKILL.md +6 -0
- package/dist/packages/pipeline/src/backends/github/GithubBackend.js +23 -3
- package/dist/packages/pipeline/src/backends/github/GithubBackend.js.map +1 -1
- package/dist/packages/pipeline/src/backends/github/createGithubJobs.js +2 -2
- package/dist/packages/pipeline/src/backends/github/createGithubJobs.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/GitlabBackend.js +18 -2
- package/dist/packages/pipeline/src/backends/gitlab/GitlabBackend.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabJobs.js +2 -2
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabJobs.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.d.ts +6 -1
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.js +8 -1
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.js.map +1 -1
- package/dist/packages/pipeline/src/config/configruedEnvs.d.ts +9 -2
- package/dist/packages/pipeline/src/config/configruedEnvs.js +54 -5
- package/dist/packages/pipeline/src/config/configruedEnvs.js.map +1 -1
- package/dist/packages/pipeline/src/context/createAllComponentsContext.d.ts +2 -2
- package/dist/packages/pipeline/src/context/createComponentContext.d.ts +2 -2
- package/dist/packages/pipeline/src/context/createWorkspaceContext.d.ts +2 -2
- package/dist/packages/pipeline/src/context/getEnvConfig.js +35 -19
- package/dist/packages/pipeline/src/context/getEnvConfig.js.map +1 -1
- package/dist/packages/pipeline/src/context/getEnvInherit.d.ts +20 -0
- package/dist/packages/pipeline/src/context/getEnvInherit.js +72 -0
- package/dist/packages/pipeline/src/context/getEnvInherit.js.map +1 -0
- package/dist/packages/pipeline/src/context/getEnvInstance.d.ts +4 -0
- package/dist/packages/pipeline/src/context/{getReviewSlug.js → getEnvInstance.js} +13 -9
- package/dist/packages/pipeline/src/context/getEnvInstance.js.map +1 -0
- package/dist/packages/pipeline/src/context/getEnvOn.d.ts +13 -0
- package/dist/packages/pipeline/src/context/getEnvOn.js +28 -0
- package/dist/packages/pipeline/src/context/getEnvOn.js.map +1 -0
- package/dist/packages/pipeline/src/context/getEnvType.d.ts +8 -2
- package/dist/packages/pipeline/src/context/getEnvType.js +27 -5
- package/dist/packages/pipeline/src/context/getEnvType.js.map +1 -1
- package/dist/packages/pipeline/src/context/getEnvironment.js +3 -0
- package/dist/packages/pipeline/src/context/getEnvironment.js.map +1 -1
- package/dist/packages/pipeline/src/context/getEnvironmentContext.js +18 -8
- package/dist/packages/pipeline/src/context/getEnvironmentContext.js.map +1 -1
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.js +4 -4
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.js.map +1 -1
- package/dist/packages/pipeline/src/context/index.d.ts +1 -0
- package/dist/packages/pipeline/src/context/index.js +1 -0
- package/dist/packages/pipeline/src/context/index.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/base/deploy.js +11 -1
- package/dist/packages/pipeline/src/deploy/base/deploy.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/artifactsRegistry.js +5 -4
- package/dist/packages/pipeline/src/deploy/cloudRun/artifactsRegistry.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/cleanup.js +8 -2
- package/dist/packages/pipeline/src/deploy/cloudRun/cleanup.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/index.js +2 -2
- package/dist/packages/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/getServiceName.js +2 -2
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/getServiceName.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/kubernetes/index.js +3 -3
- package/dist/packages/pipeline/src/deploy/kubernetes/index.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/pages/deployJob.js +3 -2
- package/dist/packages/pipeline/src/deploy/pages/deployJob.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/types/googleCloudRun.d.ts +9 -0
- package/dist/packages/pipeline/src/types/config.d.ts +126 -9
- package/dist/packages/pipeline/src/types/config.js +11 -10
- package/dist/packages/pipeline/src/types/config.js.map +1 -1
- package/dist/packages/pipeline/src/types/context.d.ts +22 -3
- package/dist/packages/pipeline/src/types/context.js.map +1 -1
- package/dist/packages/pipeline/src/types/environmentContext.d.ts +29 -0
- package/dist/skills/catladder-config/SKILL.md +34 -2
- package/dist/skills/catladder-deploys/SKILL.md +5 -0
- package/dist/skills/catladder-pipelines/SKILL.md +10 -1
- package/dist/skills/catladder-secrets/SKILL.md +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/commands/project/commandPortForward.ts +1 -1
- package/src/commands/project/secrets/scope.ts +38 -2
- package/src/config/getProjectConfig.ts +9 -1
- package/src/secrets/github.ts +8 -5
- package/dist/packages/pipeline/src/context/getReviewSlug.d.ts +0 -4
- package/dist/packages/pipeline/src/context/getReviewSlug.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAllEnvsByTrigger = exports.getAllEnvsInAllComponents = exports.getAllEnvs = void 0;
|
|
3
|
+
exports.getConfiguredBranchTriggers = exports.getAllEnvsByTrigger = exports.getAllEnvsInAllComponents = exports.getAllEnvs = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
const getEnvOn_1 = require("../context/getEnvOn");
|
|
6
|
+
const getEnvType_1 = require("../context/getEnvType");
|
|
5
7
|
const getConfiguredAndDefaultEnvs = (config, componentName, envTypes) => {
|
|
6
8
|
var _a, _b;
|
|
7
9
|
const configuredEnvs = (_a = config.components[componentName].env) !== null && _a !== void 0 ? _a : {};
|
|
@@ -9,13 +11,33 @@ const getConfiguredAndDefaultEnvs = (config, componentName, envTypes) => {
|
|
|
9
11
|
// these can be disabled with settimg them to `false`
|
|
10
12
|
// this is the list of all not disabled envs. These are always returned
|
|
11
13
|
const enabledDefaultEnvs = envTypes.filter((e) => configuredEnvs[e] !== false);
|
|
12
|
-
|
|
14
|
+
// envs declared project-wide (top-level `environments`): every
|
|
15
|
+
// component deploys to them unless it opts out with `env.<name>: false`
|
|
16
|
+
const declaredEnvs = Object.keys((_b = config.environments) !== null && _b !== void 0 ? _b : {})
|
|
17
|
+
.filter((envName) => !(0, types_1.isKnowEnvType)(envName)) // default envs are already handled above
|
|
18
|
+
.map((envName) => {
|
|
19
|
+
const envType = (0, getEnvType_1.getDeclaredEnvType)(config.environments, envName);
|
|
20
|
+
if (!envType) {
|
|
21
|
+
throw new Error(`environment "${envName}" needs a type (dev, review, stage, prod) or an inherit`);
|
|
22
|
+
}
|
|
23
|
+
return [envName, envType];
|
|
24
|
+
})
|
|
25
|
+
.filter(([envName, envType]) => envTypes.includes(envType) && configuredEnvs[envName] !== false)
|
|
26
|
+
.map(([envName]) => envName);
|
|
27
|
+
// legacy: custom envs declared per component via their `type`
|
|
28
|
+
const configuredCustomEnvs = Object.entries(configuredEnvs)
|
|
13
29
|
.filter(([, config]) => config &&
|
|
14
30
|
"type" in config &&
|
|
15
31
|
config.type &&
|
|
16
32
|
envTypes.includes(config.type))
|
|
17
33
|
.map(([envName]) => envName);
|
|
18
|
-
return [
|
|
34
|
+
return [
|
|
35
|
+
...new Set([
|
|
36
|
+
...enabledDefaultEnvs,
|
|
37
|
+
...declaredEnvs,
|
|
38
|
+
...configuredCustomEnvs,
|
|
39
|
+
]),
|
|
40
|
+
];
|
|
19
41
|
};
|
|
20
42
|
const getAllEnvs = (config, componentName) => {
|
|
21
43
|
return getConfiguredAndDefaultEnvs(config, componentName, types_1.DEFAULT_ENV_TYPES);
|
|
@@ -27,9 +49,36 @@ const getAllEnvsInAllComponents = (config) => {
|
|
|
27
49
|
];
|
|
28
50
|
};
|
|
29
51
|
exports.getAllEnvsInAllComponents = getAllEnvsInAllComponents;
|
|
52
|
+
/**
|
|
53
|
+
* the resolved `on` of one env of a component (the project-wide `on`
|
|
54
|
+
* of the env, falling back to the env type's default trigger)
|
|
55
|
+
*/
|
|
56
|
+
const getEnvOnForComponentEnv = (config, componentName, env) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const entry = (_a = config.components[componentName].env) === null || _a === void 0 ? void 0 : _a[env];
|
|
59
|
+
return (0, getEnvOn_1.getEnvOn)(env, entry && entry !== false ? entry : {}, config.environments);
|
|
60
|
+
};
|
|
30
61
|
const getAllEnvsByTrigger = (config, componentName, trigger) => {
|
|
31
|
-
|
|
32
|
-
return getConfiguredAndDefaultEnvs(config, componentName, envTypesByTrigger);
|
|
62
|
+
return (0, exports.getAllEnvs)(config, componentName).filter((env) => (0, types_1.envTriggerEquals)(getEnvOnForComponentEnv(config, componentName, env), trigger));
|
|
33
63
|
};
|
|
34
64
|
exports.getAllEnvsByTrigger = getAllEnvsByTrigger;
|
|
65
|
+
/**
|
|
66
|
+
* all branch triggers declared by any env of any component (via
|
|
67
|
+
* `on: { branch: "..." }`), deduplicated and sorted for deterministic
|
|
68
|
+
* pipeline generation. Each gets its own pipeline next to the built-in
|
|
69
|
+
* triggers.
|
|
70
|
+
*/
|
|
71
|
+
const getConfiguredBranchTriggers = (config) => {
|
|
72
|
+
const branches = new Set();
|
|
73
|
+
for (const componentName of Object.keys(config.components)) {
|
|
74
|
+
for (const env of (0, exports.getAllEnvs)(config, componentName)) {
|
|
75
|
+
const on = getEnvOnForComponentEnv(config, componentName, env);
|
|
76
|
+
if (on && (0, types_1.isBranchTrigger)(on)) {
|
|
77
|
+
branches.add(on.branch);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return [...branches].sort().map((branch) => ({ branch }));
|
|
82
|
+
};
|
|
83
|
+
exports.getConfiguredBranchTriggers = getConfiguredBranchTriggers;
|
|
35
84
|
//# sourceMappingURL=configruedEnvs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configruedEnvs.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/config/configruedEnvs.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"configruedEnvs.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/config/configruedEnvs.ts"],"names":[],"mappings":";;;AAMA,oCAKkB;AAClB,kDAA+C;AAC/C,sDAA2D;AAE3D,MAAM,2BAA2B,GAAG,CAClC,MAAc,EACd,aAAqB,EACrB,QAAmB,EACnB,EAAE;;IACF,MAAM,cAAc,GAAG,MAAA,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,GAAG,mCAAI,EAAE,CAAC;IAClE,uDAAuD;IACvD,qDAAqD;IACrD,uEAAuE;IACvE,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CACxC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,KAAK,CACnC,CAAC;IAEF,+DAA+D;IAC/D,wEAAwE;IACxE,MAAM,YAAY,GAAG,MAAM,CAAC,IA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AAM,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3D,KAAK,MAAM,GAAG,IAAI,IAAA,kBAAU,EAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;YACpD,MAAM,EAAE,GAAG,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;YAC/D,IAAI,EAAE,IAAI,IAAA,uBAAe,EAAC,EAAE,CAAC,EAAE,CAAC;gBAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC;AAbW,QAAA,2BAA2B,+BAatC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ComponentContext, PipelineType } from "../types";
|
|
2
|
-
import type { Config,
|
|
2
|
+
import type { Config, EnvPipelineTrigger } from "../types/config";
|
|
3
3
|
export type CreateAllComponentsContextProps = {
|
|
4
4
|
config: Config;
|
|
5
|
-
trigger:
|
|
5
|
+
trigger: EnvPipelineTrigger;
|
|
6
6
|
pipelineType: PipelineType;
|
|
7
7
|
};
|
|
8
8
|
export declare const createAllComponentsContext: ({ config, trigger, pipelineType, }: CreateAllComponentsContextProps) => Promise<Array<ComponentContext>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PipelineType } from "../types";
|
|
2
|
-
import type { Config,
|
|
2
|
+
import type { Config, EnvPipelineTrigger } from "../types/config";
|
|
3
3
|
import type { ComponentContext } from "../types/context";
|
|
4
4
|
export type CreateComponentContextContext = {
|
|
5
5
|
config: Config;
|
|
6
6
|
componentName: string;
|
|
7
7
|
env: string;
|
|
8
8
|
pipelineType?: PipelineType;
|
|
9
|
-
trigger?:
|
|
9
|
+
trigger?: EnvPipelineTrigger;
|
|
10
10
|
};
|
|
11
11
|
export declare const createComponentContext: (ctx: CreateComponentContextContext) => Promise<ComponentContext>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type Config, type
|
|
1
|
+
import { type Config, type EnvPipelineTrigger, type PipelineType, type WorkspaceContext } from "..";
|
|
2
2
|
export declare function createWorkspaceContext({ env, components, workspaceName, config, pipelineType, trigger, }: {
|
|
3
3
|
env: string;
|
|
4
4
|
components: WorkspaceContext["components"];
|
|
5
5
|
workspaceName: string;
|
|
6
6
|
config: Config;
|
|
7
7
|
pipelineType: PipelineType;
|
|
8
|
-
trigger:
|
|
8
|
+
trigger: EnvPipelineTrigger;
|
|
9
9
|
}): Promise<WorkspaceContext>;
|
|
@@ -2,33 +2,49 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEnvConfig = void 0;
|
|
4
4
|
const lodash_es_1 = require("lodash-es");
|
|
5
|
+
const getEnvInherit_1 = require("./getEnvInherit");
|
|
5
6
|
const getEnvConfig = (config, componentName, env) => {
|
|
6
|
-
var _a
|
|
7
|
+
var _a;
|
|
7
8
|
const defaultConfig = config.components[componentName];
|
|
8
9
|
if (!defaultConfig) {
|
|
9
10
|
throw new Error("unknown component " + componentName);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* env config is merged with default. Arrays are not merged.
|
|
18
|
-
* you can customize this by providing a function that takes the default value as argument
|
|
19
|
-
*/
|
|
20
|
-
return (0, lodash_es_1.mergeWith)(
|
|
12
|
+
// env config is layered onto the component config: the per-component
|
|
13
|
+
// overrides of inherited envs first (oldest ancestor first, see
|
|
14
|
+
// `environments.<name>.inherit`), the env's own overrides last
|
|
15
|
+
const chain = [...(0, getEnvInherit_1.getInheritedConfigChain)(config.environments, env), env];
|
|
21
16
|
// mergeWith unfortunatly mutates the first object, so we need to clone it.
|
|
22
17
|
// Passing empty object also doesn't work for us, because that will mess with the customizer function (second argument isn't nessecary the customized value)
|
|
23
|
-
(0, lodash_es_1.cloneDeep)(defaultConfig)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
const result = (0, lodash_es_1.cloneDeep)(defaultConfig);
|
|
19
|
+
for (const chainEnv of chain) {
|
|
20
|
+
const envCustomizations = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[chainEnv];
|
|
21
|
+
if (!envCustomizations || envCustomizations === false) {
|
|
22
|
+
if (chainEnv === env && envCustomizations === false) {
|
|
23
|
+
// env is disabled, still return the default config
|
|
24
|
+
return defaultConfig;
|
|
25
|
+
}
|
|
26
|
+
continue;
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
/**
|
|
29
|
+
* env config is merged with default. Arrays are not merged.
|
|
30
|
+
* you can customize this by providing a function that takes the default value as argument
|
|
31
|
+
*/
|
|
32
|
+
(0, lodash_es_1.mergeWith)(result,
|
|
33
|
+
// `host` must stay unique per env and `type` is the inherited
|
|
34
|
+
// env's identity — neither is inherited
|
|
35
|
+
chainEnv === env
|
|
36
|
+
? envCustomizations
|
|
37
|
+
: (0, lodash_es_1.omit)(envCustomizations, ["host", "type"]), (defaultValue, customValue, key, obj, source) => {
|
|
38
|
+
// check if custom value is a function (and default is not),
|
|
39
|
+
// we currently don't have config options, that are functions, but we might in the future (customJobs is an exception)
|
|
40
|
+
if (typeof customValue === "function" &&
|
|
41
|
+
typeof defaultValue !== "function") {
|
|
42
|
+
return customValue(defaultValue);
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
32
48
|
};
|
|
33
49
|
exports.getEnvConfig = getEnvConfig;
|
|
34
50
|
//# sourceMappingURL=getEnvConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvConfig.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvConfig.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"getEnvConfig.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvConfig.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AAEvD,mDAA0D;AAEnD,MAAM,YAAY,GAAG,CAC1B,MAAc,EACd,aAAqB,EACrB,GAAW,EACa,EAAE;;IAC1B,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,aAAa,CAAC,CAAC;IACxD,CAAC;IAED,qEAAqE;IACrE,gEAAgE;IAChE,+DAA+D;IAC/D,MAAM,KAAK,GAAG,CAAC,GAAG,IAAA,uCAAuB,EAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAE1E,2EAA2E;IAC3E,4JAA4J;IAC5J,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;IAExC,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,iBAAiB,GAAG,MAAA,aAAa,CAAC,GAAG,0CAAG,QAAQ,CAAC,CAAC;QACxD,IAAI,CAAC,iBAAiB,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;YACtD,IAAI,QAAQ,KAAK,GAAG,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;gBACpD,mDAAmD;gBACnD,OAAO,aAAa,CAAC;YACvB,CAAC;YACD,SAAS;QACX,CAAC;QACD;;;WAGG;QACH,IAAA,qBAAS,EACP,MAAM;QACN,8DAA8D;QAC9D,wCAAwC;QACxC,QAAQ,KAAK,GAAG;YACd,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,IAAA,gBAAI,EAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC7C,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;YAC9C,4DAA4D;YAC5D,sHAAsH;YACtH,IACE,OAAO,WAAW,KAAK,UAAU;gBACjC,OAAO,YAAY,KAAK,UAAU,EAClC,CAAC;gBACD,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAvDW,QAAA,YAAY,gBAuDvB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EnvironmentConfig } from "../types/config";
|
|
2
|
+
type Environments = Record<string, EnvironmentConfig> | undefined;
|
|
3
|
+
export type NormalizedEnvInherit = {
|
|
4
|
+
config?: string;
|
|
5
|
+
secrets?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const normalizeEnvInherit: (inherit: EnvironmentConfig["inherit"]) => NormalizedEnvInherit;
|
|
8
|
+
/**
|
|
9
|
+
* the chain of envs whose per-component config overrides feed into
|
|
10
|
+
* `env`, oldest ancestor first (env itself not included). Cycles and
|
|
11
|
+
* unknown/`local` targets are an error.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getInheritedConfigChain: (environments: Environments, env: string) => string[];
|
|
14
|
+
/**
|
|
15
|
+
* the env whose secret values `env` uses (follows `inherit` secret
|
|
16
|
+
* sharing transitively; the env itself when it has its own secrets).
|
|
17
|
+
* All secret variable names must be built with this env.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getSecretsEnv: (environments: Environments, env: string) => string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSecretsEnv = exports.getInheritedConfigChain = exports.normalizeEnvInherit = void 0;
|
|
4
|
+
const config_1 = require("../types/config");
|
|
5
|
+
const normalizeEnvInherit = (inherit) => {
|
|
6
|
+
if (!inherit)
|
|
7
|
+
return {};
|
|
8
|
+
if (typeof inherit === "string") {
|
|
9
|
+
return { config: inherit, secrets: inherit };
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
config: inherit.config,
|
|
13
|
+
secrets: inherit.secrets === false ? undefined : inherit.secrets,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.normalizeEnvInherit = normalizeEnvInherit;
|
|
17
|
+
const assertValidInheritTarget = (environments, env, target) => {
|
|
18
|
+
if (target === "local") {
|
|
19
|
+
throw new Error(`environment "${env}" cannot inherit from "local" — local is not a deployment environment`);
|
|
20
|
+
}
|
|
21
|
+
if (!(0, config_1.isKnowEnvType)(target) && !(environments === null || environments === void 0 ? void 0 : environments[target])) {
|
|
22
|
+
throw new Error(`environment "${env}" inherits from unknown environment "${target}"`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* the chain of envs whose per-component config overrides feed into
|
|
27
|
+
* `env`, oldest ancestor first (env itself not included). Cycles and
|
|
28
|
+
* unknown/`local` targets are an error.
|
|
29
|
+
*/
|
|
30
|
+
const getInheritedConfigChain = (environments, env) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const chain = [];
|
|
33
|
+
const seen = new Set([env]);
|
|
34
|
+
let current = env;
|
|
35
|
+
for (;;) {
|
|
36
|
+
const target = (0, exports.normalizeEnvInherit)((_a = environments === null || environments === void 0 ? void 0 : environments[current]) === null || _a === void 0 ? void 0 : _a.inherit).config;
|
|
37
|
+
if (!target)
|
|
38
|
+
break;
|
|
39
|
+
assertValidInheritTarget(environments, current, target);
|
|
40
|
+
if (seen.has(target)) {
|
|
41
|
+
throw new Error(`environment "${env}" has a cyclic config inheritance via "${target}"`);
|
|
42
|
+
}
|
|
43
|
+
seen.add(target);
|
|
44
|
+
chain.unshift(target);
|
|
45
|
+
current = target;
|
|
46
|
+
}
|
|
47
|
+
return chain;
|
|
48
|
+
};
|
|
49
|
+
exports.getInheritedConfigChain = getInheritedConfigChain;
|
|
50
|
+
/**
|
|
51
|
+
* the env whose secret values `env` uses (follows `inherit` secret
|
|
52
|
+
* sharing transitively; the env itself when it has its own secrets).
|
|
53
|
+
* All secret variable names must be built with this env.
|
|
54
|
+
*/
|
|
55
|
+
const getSecretsEnv = (environments, env) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const seen = new Set([env]);
|
|
58
|
+
let current = env;
|
|
59
|
+
for (;;) {
|
|
60
|
+
const target = (0, exports.normalizeEnvInherit)((_a = environments === null || environments === void 0 ? void 0 : environments[current]) === null || _a === void 0 ? void 0 : _a.inherit).secrets;
|
|
61
|
+
if (!target)
|
|
62
|
+
return current;
|
|
63
|
+
assertValidInheritTarget(environments, current, target);
|
|
64
|
+
if (seen.has(target)) {
|
|
65
|
+
throw new Error(`environment "${env}" has a cyclic secrets inheritance via "${target}"`);
|
|
66
|
+
}
|
|
67
|
+
seen.add(target);
|
|
68
|
+
current = target;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.getSecretsEnv = getSecretsEnv;
|
|
72
|
+
//# sourceMappingURL=getEnvInherit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEnvInherit.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvInherit.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AASzC,MAAM,mBAAmB,GAAG,CACjC,OAAqC,EACf,EAAE;IACxB,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM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;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AArBW,QAAA,uBAAuB,2BAqBlC;AAEF;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAC3B,YAA0B,EAC1B,GAAW,EACH,EAAE;;IACV,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,SAAS,CAAC;QACR,MAAM,MAAM,GAAG,IAAA,2BAAmB,EAChC,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,OAAO,CAAC,0CAAE,OAAO,CACjC,CAAC,OAAO,CAAC;QACV,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC;QAC5B,wBAAwB,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,gBAAgB,GAAG,2CAA2C,MAAM,GAAG,CACxE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,aAAa,iBAoBxB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PipelineType } from "../types";
|
|
2
|
+
import type { EnvConfigWithComponent, EnvironmentConfig } from "../types/config";
|
|
3
|
+
import type { EnvironmentInstance } from "../types/environmentContext";
|
|
4
|
+
export declare const getEnvInstance: (envConfig: EnvConfigWithComponent, env: string, pipelineType?: PipelineType, environments?: Record<string, EnvironmentConfig>) => EnvironmentInstance;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getEnvInstance = void 0;
|
|
4
4
|
const bash_1 = require("../../../bash/src/index.js");
|
|
5
5
|
const bashExpressionPerPipelineType_1 = require("../bash/bashExpressionPerPipelineType");
|
|
6
|
-
const
|
|
6
|
+
const getEnvOn_1 = require("./getEnvOn");
|
|
7
7
|
const REVIEW_SLUG = {
|
|
8
8
|
default: "unknown-review-slug",
|
|
9
9
|
gitlab: new bash_1.BashExpression(`$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })`),
|
|
10
10
|
// CL_PR_NUMBER is injected by the github backend at the workflow level
|
|
11
11
|
github: new bash_1.BashExpression(`$([ -n "$CL_PR_NUMBER" ] && echo "pr$CL_PR_NUMBER" || echo "unknown")`),
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const getEnvInstance = (envConfig, env, pipelineType, environments) => {
|
|
14
|
+
// an env deploying per merge request is a review app — one dynamic
|
|
15
|
+
// instance per MR, identified by the review slug
|
|
16
|
+
if ((0, getEnvOn_1.getEnvOn)(env, envConfig, environments) === "mr") {
|
|
17
|
+
return {
|
|
18
|
+
type: "review",
|
|
19
|
+
reviewSlug: (0, bashExpressionPerPipelineType_1.getBashExpressionPerPipelineType)(REVIEW_SLUG, pipelineType),
|
|
20
|
+
};
|
|
17
21
|
}
|
|
18
|
-
return
|
|
22
|
+
return { type: "stable" };
|
|
19
23
|
};
|
|
20
|
-
exports.
|
|
21
|
-
//# sourceMappingURL=
|
|
24
|
+
exports.getEnvInstance = getEnvInstance;
|
|
25
|
+
//# sourceMappingURL=getEnvInstance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEnvInstance.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvInstance.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEjD,yFAAyF;AAOzF,yCAAsC;AACtC,MAAM,WAAW,GAAkC;IACjD,OAAO,EAAE,qBAAqB;IAC9B,MAAM,EAAE,IAAI,qBAAc,CACxB,0JAA0J,CAC3J;IACD,uEAAuE;IACvE,MAAM,EAAE,IAAI,qBAAc,CACxB,uEAAuE,CACxE;CACF,CAAC;AAEK,MAAM,cAAc,GAAG,CAC5B,SAAiC,EACjC,GAAW,EACX,YAA2B,EAC3B,YAAgD,EAC3B,EAAE;IACvB,mEAAmE;IACnE,iDAAiD;IACjD,IAAI,IAAA,mBAAQ,EAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,IAAA,gEAAgC,EAAC,WAAW,EAAE,YAAY,CAAC;SACxE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5B,CAAC,CAAC;AAfW,QAAA,cAAc,kBAezB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EnvironmentConfig, EnvOnConfig, EnvType } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* resolves when an env deploys: the project-wide `on` config of the env
|
|
4
|
+
* (top-level `environments`), falling back to the default of its env
|
|
5
|
+
* type (dev → mainBranch, review → mr, stage/prod → taggedRelease,
|
|
6
|
+
* local → false).
|
|
7
|
+
*
|
|
8
|
+
* `on` is deliberately not configurable per component — an environment
|
|
9
|
+
* deploys at one point in time for the whole project.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getEnvOn: (env: string, envConfig: {
|
|
12
|
+
type?: EnvType;
|
|
13
|
+
}, environments?: Record<string, EnvironmentConfig>) => EnvOnConfig;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvOn = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const getEnvType_1 = require("./getEnvType");
|
|
6
|
+
const getDefaultOnForType = (envType) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const triggers = types_1.ENV_TYPES[envType].triggers;
|
|
9
|
+
return (_a = triggers[0]) !== null && _a !== void 0 ? _a : false;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* resolves when an env deploys: the project-wide `on` config of the env
|
|
13
|
+
* (top-level `environments`), falling back to the default of its env
|
|
14
|
+
* type (dev → mainBranch, review → mr, stage/prod → taggedRelease,
|
|
15
|
+
* local → false).
|
|
16
|
+
*
|
|
17
|
+
* `on` is deliberately not configurable per component — an environment
|
|
18
|
+
* deploys at one point in time for the whole project.
|
|
19
|
+
*/
|
|
20
|
+
const getEnvOn = (env, envConfig, environments) => {
|
|
21
|
+
var _a;
|
|
22
|
+
const on = (_a = environments === null || environments === void 0 ? void 0 : environments[env]) === null || _a === void 0 ? void 0 : _a.on;
|
|
23
|
+
if (on !== undefined)
|
|
24
|
+
return on;
|
|
25
|
+
return getDefaultOnForType((0, getEnvType_1.getEnvType)(env, envConfig, environments));
|
|
26
|
+
};
|
|
27
|
+
exports.getEnvOn = getEnvOn;
|
|
28
|
+
//# sourceMappingURL=getEnvOn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEnvOn.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvOn.ts"],"names":[],"mappings":";;;AACA,oCAAqC;AACrC,6CAA0C;AAE1C,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAe,EAAE;;IAC5D,MAAM,QAAQ,GAAG,iBAAS,CAAC,OAAO,CAAC,CAAC,QAAkC,CAAC;IACvE,OAAO,MAAA,QAAQ,CAAC,CAAC,CAAC,mCAAI,KAAK,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,QAAQ,GAAG,CACtB,GAAW,EACX,SAEC,EACD,YAAgD,EACnC,EAAE;;IACf,MAAM,EAAE,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,GAAG,CAAC,0CAAE,EAAE,CAAC;IACnC,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO,mBAAmB,CAAC,IAAA,uBAAU,EAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AAVW,QAAA,QAAQ,YAUnB"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type { EnvType } from "../types";
|
|
1
|
+
import type { EnvironmentConfig, EnvType } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* the type of a project-wide declared env: its explicit `type`, its
|
|
4
|
+
* name (when it is itself an env type), or — for envs that inherit —
|
|
5
|
+
* the type of the env they inherit their config from
|
|
6
|
+
*/
|
|
7
|
+
export declare const getDeclaredEnvType: (environments: Record<string, EnvironmentConfig> | undefined, env: string, seen?: Set<string>) => EnvType | undefined;
|
|
2
8
|
export declare const getEnvType: (env: string, envConfig: {
|
|
3
9
|
type?: EnvType;
|
|
4
|
-
}) => EnvType;
|
|
10
|
+
}, environments?: Record<string, EnvironmentConfig>) => EnvType;
|
|
@@ -1,13 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEnvType = void 0;
|
|
3
|
+
exports.getEnvType = exports.getDeclaredEnvType = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const getEnvInherit_1 = require("./getEnvInherit");
|
|
6
|
+
/**
|
|
7
|
+
* the type of a project-wide declared env: its explicit `type`, its
|
|
8
|
+
* name (when it is itself an env type), or — for envs that inherit —
|
|
9
|
+
* the type of the env they inherit their config from
|
|
10
|
+
*/
|
|
11
|
+
const getDeclaredEnvType = (environments, env, seen = new Set()) => {
|
|
12
|
+
const declared = environments === null || environments === void 0 ? void 0 : environments[env];
|
|
13
|
+
if (declared === null || declared === void 0 ? void 0 : declared.type)
|
|
14
|
+
return declared.type;
|
|
15
|
+
if ((0, types_1.isKnowEnvType)(env))
|
|
9
16
|
return env;
|
|
17
|
+
const inheritTarget = (0, getEnvInherit_1.normalizeEnvInherit)(declared === null || declared === void 0 ? void 0 : declared.inherit).config;
|
|
18
|
+
if (inheritTarget && !seen.has(inheritTarget)) {
|
|
19
|
+
seen.add(inheritTarget);
|
|
20
|
+
return (0, exports.getDeclaredEnvType)(environments, inheritTarget, seen);
|
|
10
21
|
}
|
|
22
|
+
return undefined;
|
|
23
|
+
};
|
|
24
|
+
exports.getDeclaredEnvType = getDeclaredEnvType;
|
|
25
|
+
const getEnvType = (env, envConfig, environments) => {
|
|
26
|
+
// legacy: per-component custom envs declare their type themselves
|
|
27
|
+
if (envConfig.type)
|
|
28
|
+
return envConfig.type;
|
|
29
|
+
// project-wide declaration (top-level `environments`)
|
|
30
|
+
const declaredType = (0, exports.getDeclaredEnvType)(environments, env);
|
|
31
|
+
if (declaredType)
|
|
32
|
+
return declaredType;
|
|
11
33
|
throw new Error("unknown env type: " + env);
|
|
12
34
|
};
|
|
13
35
|
exports.getEnvType = getEnvType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvType.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvType.ts"],"names":[],"mappings":";;;AACA,oCAAyC;
|
|
1
|
+
{"version":3,"file":"getEnvType.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvType.ts"],"names":[],"mappings":";;;AACA,oCAAyC;AACzC,mDAAsD;AAEtD;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAChC,YAA2D,EAC3D,GAAW,EACX,OAAoB,IAAI,GAAG,EAAE,EACR,EAAE;IACvB,MAAM,QAAQ,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,GAAG,CAAC,CAAC;IACrC,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzC,IAAI,IAAA,qBAAa,EAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAEnC,MAAM,aAAa,GAAG,IAAA,mCAAmB,EAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,CAAC,MAAM,CAAC;IACpE,IAAI,aAAa,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACxB,OAAO,IAAA,0BAAkB,EAAC,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAfW,QAAA,kBAAkB,sBAe7B;AAEK,MAAM,UAAU,GAAG,CACxB,GAAW,EACX,SAEC,EACD,YAAgD,EACvC,EAAE;IACX,kEAAkE;IAClE,IAAI,SAAS,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC,IAAI,CAAC;IAE1C,sDAAsD;IACtD,MAAM,YAAY,GAAG,IAAA,0BAAkB,EAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC3D,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IAEtC,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,GAAG,CAAC,CAAC;AAC9C,CAAC,CAAC;AAfW,QAAA,UAAU,cAerB"}
|
|
@@ -12,8 +12,11 @@ const getEnvironment = async (ctx) => {
|
|
|
12
12
|
envType,
|
|
13
13
|
fullName: envContext.fullName,
|
|
14
14
|
slugPrefix: envContext.environmentSlugPrefix,
|
|
15
|
+
instance: envContext.instance,
|
|
15
16
|
reviewSlug: envContext.reviewSlug,
|
|
16
17
|
slug: envContext.environmentSlug,
|
|
18
|
+
autoStop: envContext.autoStop,
|
|
19
|
+
secretsEnv: envContext.secretsEnv,
|
|
17
20
|
...variables,
|
|
18
21
|
};
|
|
19
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvironment.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvironment.ts"],"names":[],"mappings":";;;AAGA,mEAAgE;AAChE,uEAAoE;AAE7D,MAAM,cAAc,GAAG,KAAK,EACjC,GAAkC,EACZ,EAAE;IACxB,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACpB,MAAM,SAAS,GAAG,MAAM,IAAA,iDAAuB,EAAC,GAAG,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,IAAA,6CAAqB,EAAC,GAAG,CAAC,CAAC;IAE9C,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAEnC,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,UAAU,EAAE,UAAU,CAAC,qBAAqB;QAC5C,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,IAAI,EAAE,UAAU,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"getEnvironment.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvironment.ts"],"names":[],"mappings":";;;AAGA,mEAAgE;AAChE,uEAAoE;AAE7D,MAAM,cAAc,GAAG,KAAK,EACjC,GAAkC,EACZ,EAAE;IACxB,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACpB,MAAM,SAAS,GAAG,MAAM,IAAA,iDAAuB,EAAC,GAAG,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,IAAA,6CAAqB,EAAC,GAAG,CAAC,CAAC;IAE9C,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAEnC,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,UAAU,EAAE,UAAU,CAAC,qBAAqB;QAC5C,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,IAAI,EAAE,UAAU,CAAC,eAAe;QAChC,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,UAAU,EAAE,UAAU,CAAC,UAAU;QAEjC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,cAAc,kBAsBzB"}
|
|
@@ -3,19 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getEnvironmentContext = void 0;
|
|
4
4
|
const bash_1 = require("../../../bash/src/index.js");
|
|
5
5
|
const getEnvConfig_1 = require("./getEnvConfig");
|
|
6
|
+
const getEnvInstance_1 = require("./getEnvInstance");
|
|
7
|
+
const getEnvInherit_1 = require("./getEnvInherit");
|
|
6
8
|
const getEnvType_1 = require("./getEnvType");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return (0, bash_1.joinBashExpressions)([env, reviewSlug], "-");
|
|
9
|
+
const getEnvironmentSlugPrefix = (env, instance) => {
|
|
10
|
+
if (instance.type === "review") {
|
|
11
|
+
return (0, bash_1.joinBashExpressions)([env, instance.reviewSlug], "-");
|
|
11
12
|
}
|
|
12
13
|
return env;
|
|
13
14
|
};
|
|
14
15
|
const getEnvironmentContext = ({ env, componentName, config, pipelineType, }) => {
|
|
16
|
+
var _a, _b;
|
|
15
17
|
const envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
|
|
16
|
-
const envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw, config.environments);
|
|
19
|
+
const instance = (0, getEnvInstance_1.getEnvInstance)(envConfigRaw, env, pipelineType, config.environments);
|
|
20
|
+
// component-level autoStop overrides the project-wide environment
|
|
21
|
+
// config; undefined means the env type's default applies
|
|
22
|
+
const autoStop = envConfigRaw.autoStop !== undefined
|
|
23
|
+
? envConfigRaw.autoStop
|
|
24
|
+
: (_b = (_a = config.environments) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.autoStop;
|
|
25
|
+
const environmentSlugPrefix = getEnvironmentSlugPrefix(env, instance);
|
|
19
26
|
const environmentSlug = environmentSlugPrefix.concat(`-${componentName}`);
|
|
20
27
|
const fullName = (0, bash_1.joinBashExpressions)([config.customerName, config.appName, environmentSlug], "-");
|
|
21
28
|
return {
|
|
@@ -24,10 +31,13 @@ const getEnvironmentContext = ({ env, componentName, config, pipelineType, }) =>
|
|
|
24
31
|
buildConfigRaw: envConfigRaw.build,
|
|
25
32
|
environmentSlugPrefix,
|
|
26
33
|
environmentSlug,
|
|
27
|
-
|
|
34
|
+
instance,
|
|
35
|
+
reviewSlug: instance.type === "review" ? instance.reviewSlug : null,
|
|
28
36
|
pipelineType,
|
|
29
37
|
fullName,
|
|
30
38
|
envType,
|
|
39
|
+
autoStop,
|
|
40
|
+
secretsEnv: (0, getEnvInherit_1.getSecretsEnv)(config.environments, env),
|
|
31
41
|
componentName,
|
|
32
42
|
env,
|
|
33
43
|
fullConfig: config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvironmentContext.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvironmentContext.ts"],"names":[],"mappings":";;;AAEA,0CAAsD;
|
|
1
|
+
{"version":3,"file":"getEnvironmentContext.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getEnvironmentContext.ts"],"names":[],"mappings":";;;AAEA,0CAAsD;AAMtD,iDAA8C;AAC9C,qDAAkD;AAClD,mDAAgD;AAChD,6CAA0C;AAE1C,MAAM,wBAAwB,GAAG,CAC/B,GAAW,EACX,QAA6B,EACL,EAAE;IAC1B,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE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QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;QACnE,YAAY;QACZ,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,UAAU,EAAE,IAAA,6BAAa,EAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC;QACnD,aAAa;QACb,GAAG;QACH,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,qBAAqB,yBAgDhC"}
|
|
@@ -17,7 +17,7 @@ export type SecretEnvVar = {
|
|
|
17
17
|
declare const getBasePredefinedVariables: (ctx: EnvironmentContext) => {
|
|
18
18
|
ENV_SHORT: string;
|
|
19
19
|
APP_DIR: string;
|
|
20
|
-
ENV_TYPE: "stage" | "prod" | "local" | "
|
|
20
|
+
ENV_TYPE: "stage" | "prod" | "local" | "review" | "dev";
|
|
21
21
|
};
|
|
22
22
|
type BasePredefinedVariables = ReturnType<typeof getBasePredefinedVariables>;
|
|
23
23
|
export type PredefinedVariables = BasePredefinedVariables & {
|
|
@@ -68,7 +68,7 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
68
68
|
...(0, envVars_1.normalizeSecretVarsConfig)((_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.secret),
|
|
69
69
|
...additionalSecretKeys,
|
|
70
70
|
];
|
|
71
|
-
const secretEnvVars = (0, envVars_1.makeSecretEnvVarMapping)(
|
|
71
|
+
const secretEnvVars = (0, envVars_1.makeSecretEnvVarMapping)(environmentContext.secretsEnv, componentName, secretEnvVarKeys);
|
|
72
72
|
const publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRaw);
|
|
73
73
|
const publicEnvVarsUnresolved = Object.fromEntries(Object.entries(publicEnvVarsRawSanitized).map(([key, value]) => [
|
|
74
74
|
key,
|
|
@@ -102,11 +102,11 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
102
102
|
envVars,
|
|
103
103
|
secretEnvVarKeys,
|
|
104
104
|
jobOnlyVars: {
|
|
105
|
-
build: await (0, transformJobOnlyVars_1.transformJobOnlyVars)(
|
|
105
|
+
build: await (0, transformJobOnlyVars_1.transformJobOnlyVars)(environmentContext.secretsEnv, componentName, (buildConfigRaw &&
|
|
106
106
|
(0, types_1.isStandaloneBuildConfig)(buildConfigRaw) &&
|
|
107
107
|
buildConfigRaw.jobVars) ||
|
|
108
108
|
null),
|
|
109
|
-
deploy: await (0, transformJobOnlyVars_1.transformJobOnlyVars)(
|
|
109
|
+
deploy: await (0, transformJobOnlyVars_1.transformJobOnlyVars)(environmentContext.secretsEnv, componentName, (deployConfigRaw && deployConfigRaw.jobVars) || null),
|
|
110
110
|
},
|
|
111
111
|
};
|
|
112
112
|
};
|
|
@@ -118,6 +118,6 @@ const addIndexVar = (vars) => ({
|
|
|
118
118
|
...vars,
|
|
119
119
|
_ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars)),
|
|
120
120
|
});
|
|
121
|
-
const getSecretVarNameForContext = (context, key) => (0, exports.getSecretVarName)(context.
|
|
121
|
+
const getSecretVarNameForContext = (context, key) => (0, exports.getSecretVarName)(context.environment.secretsEnv, context.name, key);
|
|
122
122
|
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
|
123
123
|
//# sourceMappingURL=getEnvironmentVariables.js.map
|