@catladder/cli 5.1.3 → 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 +419 -106
- package/dist/bundles/cli/index.js +449 -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 +42 -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 +24 -1
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.d.ts +17 -0
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.js +13 -0
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.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/packages/pipeline/src/types/gitlab-types.d.ts +29 -1
- 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 +42 -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
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ export const commandPortForward = defineCommand({
|
|
|
59
59
|
|
|
60
60
|
const { fullName } = context.environment;
|
|
61
61
|
let serviceName: string = fullName.toString();
|
|
62
|
-
if (context.environment.
|
|
62
|
+
if (context.environment.instance.type === "review") {
|
|
63
63
|
const mr = await ctx.get("mr");
|
|
64
64
|
serviceName = serviceName
|
|
65
65
|
.toString()
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { getSecretsEnv } from "@catladder/pipeline";
|
|
1
2
|
import {
|
|
2
3
|
getAllComponentsWithAllEnvsHierarchical,
|
|
3
4
|
getEnvironment,
|
|
5
|
+
getProjectConfig,
|
|
4
6
|
} from "../../../config/getProjectConfig";
|
|
5
7
|
|
|
6
8
|
/** which envs of which components a secrets command operates on */
|
|
@@ -8,6 +10,26 @@ export type SecretsScope = {
|
|
|
8
10
|
[componentName: string]: string[];
|
|
9
11
|
};
|
|
10
12
|
|
|
13
|
+
/**
|
|
14
|
+
* envs that share another env's secrets (`environments.<name>.inherit`)
|
|
15
|
+
* have no secret store of their own — the secrets commands operate on
|
|
16
|
+
* the source env instead
|
|
17
|
+
*/
|
|
18
|
+
const withoutSharedSecretEnvs = async (
|
|
19
|
+
all: SecretsScope,
|
|
20
|
+
): Promise<SecretsScope> => {
|
|
21
|
+
const config = await getProjectConfig();
|
|
22
|
+
const environments = config?.environments;
|
|
23
|
+
return Object.fromEntries(
|
|
24
|
+
Object.entries(all)
|
|
25
|
+
.map(([componentName, envs]): [string, string[]] => [
|
|
26
|
+
componentName,
|
|
27
|
+
envs.filter((env) => getSecretsEnv(environments, env) === env),
|
|
28
|
+
])
|
|
29
|
+
.filter(([, envs]) => envs.length > 0),
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
11
33
|
/**
|
|
12
34
|
* resolves a scope expression to component → envs:
|
|
13
35
|
* - (empty): all components, all envs
|
|
@@ -18,7 +40,9 @@ export type SecretsScope = {
|
|
|
18
40
|
export const resolveSecretsScope = async (
|
|
19
41
|
scope?: string,
|
|
20
42
|
): Promise<SecretsScope> => {
|
|
21
|
-
const all = await
|
|
43
|
+
const all = await withoutSharedSecretEnvs(
|
|
44
|
+
await getAllComponentsWithAllEnvsHierarchical(),
|
|
45
|
+
);
|
|
22
46
|
if (Object.keys(all).length === 0) {
|
|
23
47
|
throw new Error("no catladder config found");
|
|
24
48
|
}
|
|
@@ -28,6 +52,16 @@ export const resolveSecretsScope = async (
|
|
|
28
52
|
|
|
29
53
|
const [env, componentName] = scope.split(":").map((x) => x || null);
|
|
30
54
|
|
|
55
|
+
if (env) {
|
|
56
|
+
const config = await getProjectConfig();
|
|
57
|
+
const secretsEnv = getSecretsEnv(config?.environments, env);
|
|
58
|
+
if (secretsEnv !== env) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`environment "${env}" shares its secrets with "${secretsEnv}" (environments.${env}.inherit) — manage them via "${secretsEnv}"`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
31
65
|
if (componentName && !(componentName in all)) {
|
|
32
66
|
throw new Error(
|
|
33
67
|
`unknown component "${componentName}" — components: ${Object.keys(all).join(", ")}`,
|
|
@@ -59,7 +93,9 @@ export const resolveSecretsScope = async (
|
|
|
59
93
|
* (one component, all envs) forms
|
|
60
94
|
*/
|
|
61
95
|
export const secretsScopeChoices = async (): Promise<string[]> => {
|
|
62
|
-
const all = await
|
|
96
|
+
const all = await withoutSharedSecretEnvs(
|
|
97
|
+
await getAllComponentsWithAllEnvsHierarchical(),
|
|
98
|
+
);
|
|
63
99
|
const pairs = Object.entries(all).flatMap(([componentName, envs]) =>
|
|
64
100
|
envs.map((env) => `${env}:${componentName}`),
|
|
65
101
|
);
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getAllEnvs,
|
|
9
9
|
getEnvironment as _getEnvironment,
|
|
10
10
|
createComponentContext,
|
|
11
|
+
getSecretsEnv,
|
|
11
12
|
getSecretVarName,
|
|
12
13
|
} from "@catladder/pipeline";
|
|
13
14
|
|
|
@@ -125,7 +126,14 @@ export const getGitlabVar = async (
|
|
|
125
126
|
componentName: string,
|
|
126
127
|
variableName: string,
|
|
127
128
|
) => {
|
|
128
|
-
const
|
|
129
|
+
const config = await getProjectConfig();
|
|
130
|
+
// an env sharing another env's secrets (inherit) reads that env's variables
|
|
131
|
+
const secretsEnv = getSecretsEnv(config?.environments, env);
|
|
132
|
+
const rawVariableName = getSecretVarName(
|
|
133
|
+
secretsEnv,
|
|
134
|
+
componentName,
|
|
135
|
+
variableName,
|
|
136
|
+
);
|
|
129
137
|
return await getVariableValueByRawName(io, rawVariableName);
|
|
130
138
|
};
|
|
131
139
|
|
package/src/secrets/github.ts
CHANGED
|
@@ -30,17 +30,20 @@ export const collectSecretsFromVault = async (io: IO, envFilter?: string[]) => {
|
|
|
30
30
|
if (envFilter && !envFilter.includes(env)) {
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
|
-
const { secretEnvVarKeys, jobOnlyVars } =
|
|
34
|
-
env,
|
|
35
|
-
componentName,
|
|
36
|
-
);
|
|
33
|
+
const { secretEnvVarKeys, jobOnlyVars, secretsEnv } =
|
|
34
|
+
await getEnvironment(env, componentName);
|
|
37
35
|
const keys = [
|
|
38
36
|
...secretEnvVarKeys,
|
|
39
37
|
...jobOnlyVars.build.secretEnvVarKeys,
|
|
40
38
|
...jobOnlyVars.deploy.secretEnvVarKeys,
|
|
41
39
|
];
|
|
40
|
+
// secretsEnv: an env sharing another env's secrets (inherit)
|
|
41
|
+
// references that env's variable names
|
|
42
42
|
keys.forEach(({ key, kind }) =>
|
|
43
|
-
kinds.set(
|
|
43
|
+
kinds.set(
|
|
44
|
+
getSecretVarName(secretsEnv ?? env, componentName, key),
|
|
45
|
+
kind ?? "secret",
|
|
46
|
+
),
|
|
44
47
|
);
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type StringOrBashExpression } from "../../../bash/src/index.js";
|
|
2
|
-
import type { PipelineType } from "../types";
|
|
3
|
-
import type { EnvConfigWithComponent } from "../types/config";
|
|
4
|
-
export declare const getReviewSlug: (envConfig: EnvConfigWithComponent, env: string, pipelineType?: PipelineType) => StringOrBashExpression | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getReviewSlug.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/context/getReviewSlug.ts"],"names":[],"mappings":";;;AAAA,0CAA8E;AAE9E,yFAAyF;AAGzF,6CAA0C;AAC1C,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,aAAa,GAAG,CAC3B,SAAiC,EACjC,GAAW,EACX,YAA2B,EACI,EAAE;IACjC,MAAM,OAAO,GAAG,IAAA,uBAAU,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC3C,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,IAAA,gEAAgC,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,oBAAoB;AACnC,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB"}
|