@catladder/pipeline 1.59.0 → 1.60.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/deploy/cloudRun/deployJob.js +22 -20
- package/dist/deploy/cloudRun/index.js +53 -6
- package/dist/deploy/cloudRun/utils/database.d.ts +4 -0
- package/dist/deploy/cloudRun/utils/database.js +82 -0
- package/dist/deploy/index.d.ts +3 -2
- package/dist/deploy/index.js +1 -1
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +8 -0
- package/dist/deploy/{cloudSql → kubernetes/cloudSql}/index.js +6 -6
- package/dist/deploy/kubernetes/kubeValues.js +2 -2
- package/dist/deploy/types/googleCloudRun.d.ts +28 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.js +3 -0
- package/dist/utils/gitlab.d.ts +5 -1
- package/dist/utils/gitlab.js +14 -2
- package/examples/cloud-sql.ts +42 -0
- package/package.json +1 -2
- package/src/context/index.ts +3 -2
- package/src/deploy/cloudRun/deployJob.ts +29 -17
- package/src/deploy/cloudRun/index.ts +47 -3
- package/src/deploy/cloudRun/utils/database.ts +55 -0
- package/src/deploy/index.ts +3 -2
- package/src/deploy/{cloudSql → kubernetes/cloudSql}/index.ts +4 -4
- package/src/deploy/kubernetes/kubeValues.ts +2 -2
- package/src/deploy/types/googleCloudRun.ts +26 -1
- package/src/types/config.ts +2 -1
- package/src/types/utils.ts +7 -0
- package/src/utils/gitlab.ts +18 -0
- package/dist/deploy/cloudSql/index.d.ts +0 -8
- package/examples/test.catladder.ts +0 -26
package/src/deploy/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Context } from "../types/context";
|
|
2
2
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
3
|
import type { CatladderJob } from "../types/jobs";
|
|
4
|
+
import type { PartialDeep } from "../types/utils";
|
|
4
5
|
import { GCLOUD_RUN_DEPLOY_TYPE } from "./cloudRun";
|
|
5
6
|
import { CUSTOM_DEPLOY_TYPE } from "./custom";
|
|
6
7
|
import { DOCKER_TAG_DEPLOY_TYPE } from "./dockerTag";
|
|
7
8
|
import { KUBERNETES_DEPLOY_TYPE } from "./kubernetes";
|
|
8
9
|
import type { DeployConfigGeneric, DeployConfigType } from "./types";
|
|
9
10
|
export * from "./cloudRun";
|
|
10
|
-
export * from "./cloudSql";
|
|
11
|
+
export * from "./kubernetes/cloudSql";
|
|
11
12
|
export * from "./kubernetes";
|
|
12
13
|
export * from "./types";
|
|
13
14
|
export * from "./utils";
|
|
@@ -16,7 +17,7 @@ export type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
|
16
17
|
jobs: (context: Context) => CatladderJob[];
|
|
17
18
|
defaults: (
|
|
18
19
|
envContext: EnvironmentContext<any, T>
|
|
19
|
-
) =>
|
|
20
|
+
) => PartialDeep<DeployConfigGeneric<T>>;
|
|
20
21
|
additionalSecretKeys: (envContext: EnvironmentContext<any, T>) => string[];
|
|
21
22
|
getAdditionalEnvVars: (
|
|
22
23
|
envContext: EnvironmentContext<any, T>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { Context } from "
|
|
2
|
-
import { isOfDeployType } from "
|
|
1
|
+
import type { Context } from "../../../types";
|
|
2
|
+
import { isOfDeployType } from "../../types";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const hasKubernetesCloudSQL = (context: Context) => {
|
|
5
5
|
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
6
6
|
return context.componentConfig.deploy.values?.cloudsql?.enabled;
|
|
7
7
|
}
|
|
8
8
|
return false;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const getKubernetesCloudSQLConfig = (context: Context) => {
|
|
12
12
|
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
13
13
|
return context.componentConfig.deploy.values?.cloudsql;
|
|
14
14
|
}
|
|
@@ -2,7 +2,7 @@ import { merge } from "lodash";
|
|
|
2
2
|
|
|
3
3
|
import type { Context } from "../../types/context";
|
|
4
4
|
import { mergeWithMergingArrays } from "../../utils";
|
|
5
|
-
import {
|
|
5
|
+
import { hasKubernetesCloudSQL } from "./cloudSql";
|
|
6
6
|
import type { DeployConfigKubernetesValues } from "../types";
|
|
7
7
|
import { isOfDeployType } from "../types";
|
|
8
8
|
import { createCloudsqlBaseConfig } from "./cloudsql";
|
|
@@ -68,7 +68,7 @@ export const createKubeValues = (context: Context) => {
|
|
|
68
68
|
env,
|
|
69
69
|
application: createAppConfig(context, application),
|
|
70
70
|
},
|
|
71
|
-
|
|
71
|
+
hasKubernetesCloudSQL(context) ? createCloudsqlBaseConfig(context) : {},
|
|
72
72
|
deployConfig.values?.mongodb?.enabled
|
|
73
73
|
? createMongodbBaseConfig(context)
|
|
74
74
|
: {}
|
|
@@ -37,6 +37,21 @@ export type Gcloudregion =
|
|
|
37
37
|
| "us-west3"
|
|
38
38
|
| "us-west4";
|
|
39
39
|
|
|
40
|
+
export type DeployConfigCloudRunCloudSql = {
|
|
41
|
+
type: "unmanaged";
|
|
42
|
+
instanceConnectionName: string;
|
|
43
|
+
/**
|
|
44
|
+
* the prefix of the database, the full db name is this plus the environment slug
|
|
45
|
+
*
|
|
46
|
+
* defaults to customerName-appName
|
|
47
|
+
*/
|
|
48
|
+
dbNamePrefix?: string | false;
|
|
49
|
+
/**
|
|
50
|
+
* whether to delete the database if the environment is stopped
|
|
51
|
+
* defaults to true for review envs, to false for every other environment
|
|
52
|
+
*/
|
|
53
|
+
deleteDatabaseOnStop?: boolean;
|
|
54
|
+
};
|
|
40
55
|
export type DeployConfigCloudRunService = {
|
|
41
56
|
/**
|
|
42
57
|
* command / entrypoint, fallsback to buildConfig.startcommand
|
|
@@ -51,6 +66,11 @@ export type DeployConfigCloudRunJob = {
|
|
|
51
66
|
command: string;
|
|
52
67
|
|
|
53
68
|
when: "manual" | "preDeploy" | "postDeploy";
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* memory limit of the job, defaults to 51Mi
|
|
72
|
+
*/
|
|
73
|
+
memory?: `${number}${"M" | "G" | "Mi" | "Gi"}`;
|
|
54
74
|
};
|
|
55
75
|
export type DeployConfigCloudRun = {
|
|
56
76
|
/**
|
|
@@ -76,6 +96,11 @@ export type DeployConfigCloudRun = {
|
|
|
76
96
|
service?: boolean | DeployConfigCloudRunService;
|
|
77
97
|
|
|
78
98
|
jobs?: {
|
|
79
|
-
[name: string]: DeployConfigCloudRunJob;
|
|
99
|
+
[name: string]: DeployConfigCloudRunJob | false | null;
|
|
80
100
|
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* add cloudSql
|
|
104
|
+
*/
|
|
105
|
+
cloudSql?: DeployConfigCloudRunCloudSql | false;
|
|
81
106
|
} & DeployConfigBase;
|
package/src/types/config.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { BuildConfig } from "../build/types";
|
|
2
2
|
import type { DeployConfig } from "../deploy/types";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import type { CatladderJob } from "./jobs";
|
|
5
5
|
import type { Context } from "./context";
|
|
6
|
+
import type { PartialDeep } from "./utils";
|
|
6
7
|
export type PipelineTrigger = "mainBranch" | "mr" | "taggedRelease";
|
|
7
8
|
|
|
8
9
|
/**
|
package/src/utils/gitlab.ts
CHANGED
|
@@ -3,3 +3,21 @@ export const allowFailureInScripts = (script: string[]): string[] => [
|
|
|
3
3
|
...script,
|
|
4
4
|
"set -e", // reenable
|
|
5
5
|
];
|
|
6
|
+
|
|
7
|
+
export const sanitizeForBashVariable = (name: string) =>
|
|
8
|
+
name.replace(/-/g, "_");
|
|
9
|
+
|
|
10
|
+
export const repeatOnFailure = (
|
|
11
|
+
command: string,
|
|
12
|
+
options: {
|
|
13
|
+
pauseInSeconds: number;
|
|
14
|
+
}
|
|
15
|
+
): string => {
|
|
16
|
+
return `
|
|
17
|
+
until ${command} &> /dev/null
|
|
18
|
+
do
|
|
19
|
+
echo "Trying again."
|
|
20
|
+
sleep ${options.pauseInSeconds}
|
|
21
|
+
done
|
|
22
|
+
`;
|
|
23
|
+
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Context } from "../../types";
|
|
2
|
-
export declare const hasCloudSQL: (context: Context) => boolean | undefined;
|
|
3
|
-
export declare const getCloudSQLConfig: (context: Context) => {
|
|
4
|
-
enabled: boolean;
|
|
5
|
-
instanceId?: string | undefined;
|
|
6
|
-
projectId?: string | undefined;
|
|
7
|
-
region?: string | undefined;
|
|
8
|
-
} | undefined;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Config } from "../src";
|
|
2
|
-
|
|
3
|
-
const config: Config = {
|
|
4
|
-
appName: "test-app",
|
|
5
|
-
customerName: "pan",
|
|
6
|
-
components: {
|
|
7
|
-
api: {
|
|
8
|
-
dir: "api",
|
|
9
|
-
build: {
|
|
10
|
-
type: "node",
|
|
11
|
-
},
|
|
12
|
-
deploy: {
|
|
13
|
-
type: "google-cloudrun",
|
|
14
|
-
projectId: "asdf",
|
|
15
|
-
region: "asia-east1",
|
|
16
|
-
jobs: {
|
|
17
|
-
migration: {
|
|
18
|
-
command: "yarn migrate",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default config;
|