@catladder/pipeline 1.89.4 → 1.90.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/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironmentVariables.d.ts +5 -1
- package/dist/context/getEnvironmentVariables.js +7 -2
- package/dist/deploy/cloudRun/index.js +9 -1
- package/dist/deploy/custom/deployJob.js +6 -3
- package/dist/deploy/index.d.ts +2 -1
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
- package/dist/deploy/kubernetes/additionalSecretKeys.js +5 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/context.d.ts +2 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +24 -12
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +24 -12
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +24 -12
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +48 -24
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +48 -24
- package/examples/__snapshots__/custom-build-job.ts.snap +24 -12
- package/examples/__snapshots__/custom-deploy.ts.snap +1384 -0
- package/examples/custom-deploy.ts +25 -0
- package/package.json +1 -1
- package/src/context/getEnvironmentVariables.ts +9 -4
- package/src/deploy/cloudRun/deployJob.ts +1 -1
- package/src/deploy/cloudRun/index.ts +9 -2
- package/src/deploy/custom/deployJob.ts +9 -1
- package/src/deploy/index.ts +4 -1
- package/src/deploy/kubernetes/additionalSecretKeys.ts +1 -1
- package/src/types/context.ts +2 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const config: Config = {
|
|
5
|
+
appName: "test-app",
|
|
6
|
+
customerName: "pan",
|
|
7
|
+
components: {
|
|
8
|
+
www: {
|
|
9
|
+
dir: "www",
|
|
10
|
+
build: {
|
|
11
|
+
type: "node",
|
|
12
|
+
},
|
|
13
|
+
deploy: {
|
|
14
|
+
type: "custom",
|
|
15
|
+
requiresDocker: true,
|
|
16
|
+
script: ["echo 'would deploy'"],
|
|
17
|
+
stopScript: ["echo 'would stop'"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
it("matches snapshot", async () => {
|
|
24
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -9,6 +9,11 @@ import {
|
|
|
9
9
|
translateLegacyFromComponents,
|
|
10
10
|
} from "./resolveReferences";
|
|
11
11
|
|
|
12
|
+
export type SecretEnvVar = {
|
|
13
|
+
key: string;
|
|
14
|
+
// hidden env vars are not shown in config-secrets
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
};
|
|
12
17
|
export const getEnvironmentVariables = async (
|
|
13
18
|
config: Config,
|
|
14
19
|
componentName: string,
|
|
@@ -17,7 +22,7 @@ export const getEnvironmentVariables = async (
|
|
|
17
22
|
alreadyVisited: Record<string, Record<string, boolean>> = {} // to prevent endless loop
|
|
18
23
|
): Promise<{
|
|
19
24
|
envVars: Record<string, string>;
|
|
20
|
-
secretEnvVarKeys:
|
|
25
|
+
secretEnvVarKeys: SecretEnvVar[];
|
|
21
26
|
host: string;
|
|
22
27
|
url: string;
|
|
23
28
|
}> => {
|
|
@@ -81,12 +86,12 @@ export const getEnvironmentVariables = async (
|
|
|
81
86
|
)
|
|
82
87
|
: [];
|
|
83
88
|
|
|
84
|
-
const secretEnvVarKeys = [
|
|
85
|
-
...(envConfigRaw.vars?.secret ?? []),
|
|
89
|
+
const secretEnvVarKeys: SecretEnvVar[] = [
|
|
90
|
+
...(envConfigRaw.vars?.secret ?? []).map((key) => ({ key })),
|
|
86
91
|
...additionalSecretKeys,
|
|
87
92
|
];
|
|
88
93
|
const secretEnvVars = Object.fromEntries(
|
|
89
|
-
secretEnvVarKeys.map((key) => [
|
|
94
|
+
secretEnvVarKeys.map(({ key }) => [
|
|
90
95
|
key,
|
|
91
96
|
`$${getSecretVarName(env, componentName, key)}`,
|
|
92
97
|
])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dump } from "js-yaml";
|
|
2
|
-
import {
|
|
2
|
+
import { merge, omit } from "lodash";
|
|
3
3
|
import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from ".";
|
|
4
4
|
import { getDockerJobBaseProps, gitlabDockerLogin } from "../../build/docker";
|
|
5
5
|
import { getLabels } from "../../context/getLabels";
|
|
@@ -58,9 +58,16 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
|
|
|
58
58
|
return {};
|
|
59
59
|
},
|
|
60
60
|
additionalSecretKeys: (ctx) => [
|
|
61
|
-
|
|
61
|
+
{
|
|
62
|
+
key: GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
63
|
+
hidden: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
67
|
+
hidden: true,
|
|
68
|
+
},
|
|
62
69
|
...(ctx.deployConfigRaw && ctx.deployConfigRaw.cloudSql
|
|
63
|
-
? ["DB_PASSWORD"]
|
|
70
|
+
? [{ key: "DB_PASSWORD" }]
|
|
64
71
|
: []),
|
|
65
72
|
],
|
|
66
73
|
getAdditionalEnvVars: (ctx) => {
|
|
@@ -4,7 +4,7 @@ import { getYarnInstall } from "../../build/node/yarn";
|
|
|
4
4
|
import { getRunnerImage } from "../../runner";
|
|
5
5
|
import type { Context } from "../../types/context";
|
|
6
6
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
|
-
import { getBaseDeploymentJob } from "../base";
|
|
7
|
+
import { getBaseDeploymentJob, getBaseDeploymentStopJob } from "../base";
|
|
8
8
|
import { isOfDeployType } from "../types";
|
|
9
9
|
|
|
10
10
|
export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
@@ -29,5 +29,13 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
29
29
|
...deployConfig.script,
|
|
30
30
|
],
|
|
31
31
|
}),
|
|
32
|
+
...(deployConfig.stopScript
|
|
33
|
+
? [
|
|
34
|
+
merge({}, getBaseDeploymentStopJob(context), {
|
|
35
|
+
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
36
|
+
script: deployConfig.stopScript,
|
|
37
|
+
}),
|
|
38
|
+
]
|
|
39
|
+
: []),
|
|
32
40
|
];
|
|
33
41
|
};
|
package/src/deploy/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SecretEnvVar } from "..";
|
|
1
2
|
import type { Context } from "../types/context";
|
|
2
3
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
4
|
import type { CatladderJob } from "../types/jobs";
|
|
@@ -17,7 +18,9 @@ export type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
|
17
18
|
defaults: (
|
|
18
19
|
envContext: EnvironmentContext<any, T>
|
|
19
20
|
) => PartialDeep<DeployConfigGeneric<T>>;
|
|
20
|
-
additionalSecretKeys: (
|
|
21
|
+
additionalSecretKeys: (
|
|
22
|
+
envContext: EnvironmentContext<any, T>
|
|
23
|
+
) => SecretEnvVar[];
|
|
21
24
|
getAdditionalEnvVars: (
|
|
22
25
|
envContext: EnvironmentContext<any, T>
|
|
23
26
|
) => Record<string, string | undefined | null>;
|
package/src/types/context.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SecretEnvVar } from "../context";
|
|
1
2
|
import type {
|
|
2
3
|
PipelineTrigger,
|
|
3
4
|
ComponentConfig,
|
|
@@ -25,7 +26,7 @@ export type Environment = {
|
|
|
25
26
|
*/
|
|
26
27
|
envVars: Record<string, string>;
|
|
27
28
|
envType: EnvType;
|
|
28
|
-
secretEnvVarKeys:
|
|
29
|
+
secretEnvVarKeys: SecretEnvVar[];
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export type CommitInfo = {
|