@catladder/pipeline 0.0.0-kube-command-59ed84cc → 0.0.0-kubernetes-new-cloudsql-d0cdae5b
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/build/docker.d.ts +4 -18
- package/dist/build/docker.js +15 -9
- package/dist/build/rails/build.js +4 -8
- package/dist/build/rails/test.js +1 -2
- package/dist/bundles/catladder-gitlab/index.js +476 -197
- package/dist/constants.js +1 -1
- package/dist/deploy/cloudRun/index.js +5 -4
- package/dist/deploy/cloudSql/utils.d.ts +3 -0
- package/dist/deploy/cloudSql/utils.js +9 -0
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +10 -10
- package/dist/deploy/kubernetes/cloudSql/index.js +36 -15
- package/dist/deploy/kubernetes/kubeValues.d.ts +1 -6
- package/dist/deploy/kubernetes/kubeValues.js +1 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -6
- package/dist/deploy/types/kubernetes.d.ts +43 -6
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/pipeline/createAllJobs.js +164 -0
- package/dist/pipeline/createChildPipeline.js +24 -48
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -100
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -20
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -20
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -20
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -40
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +16 -40
- package/examples/__snapshots__/custom-build-job.ts.snap +8 -20
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +2240 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +2252 -0
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +48 -12
- package/examples/kubernetes-with-cloud-sql-legacy.ts +33 -0
- package/examples/kubernetes-with-cloud-sql.ts +35 -0
- package/package.json +1 -1
- package/src/build/docker.ts +13 -6
- package/src/build/index.ts +1 -1
- package/src/build/node/cache.ts +2 -2
- package/src/build/rails/build.ts +9 -6
- package/src/build/rails/test.ts +43 -39
- package/src/config/configruedEnvs.ts +2 -8
- package/src/deploy/cloudRun/index.ts +7 -8
- package/src/deploy/cloudSql/utils.ts +23 -0
- package/src/deploy/kubernetes/cloudSql/index.ts +58 -14
- package/src/deploy/kubernetes/deployJob.ts +2 -1
- package/src/deploy/kubernetes/kubeValues.ts +7 -2
- package/src/deploy/types/kubernetes.ts +48 -6
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +6 -22
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/types/gitlab-types.ts +8 -6
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -75
- package/src/pipeline/createJobs.ts +0 -196
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -25
|
@@ -89,8 +89,11 @@ application:
|
|
|
89
89
|
enabled: true
|
|
90
90
|
command: 'launcher bundle exec rake jobs:work'
|
|
91
91
|
cloudsql:
|
|
92
|
-
proxyCredentials: '$CL_dev_app_cloudsqlProxyCredentials'
|
|
93
92
|
enabled: true
|
|
93
|
+
dbUser: 'postgres'
|
|
94
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-dev'
|
|
95
|
+
proxyCredentials: '$CL_dev_app_cloudsqlProxyCredentials'
|
|
96
|
+
fullDbName: 'app'
|
|
94
97
|
projectId: 'some-project-id'
|
|
95
98
|
jobs:
|
|
96
99
|
db-migrate:
|
|
@@ -297,8 +300,11 @@ application:
|
|
|
297
300
|
enabled: true
|
|
298
301
|
command: 'launcher bundle exec rake jobs:work'
|
|
299
302
|
cloudsql:
|
|
300
|
-
proxyCredentials: '$CL_dev_app_cloudsqlProxyCredentials'
|
|
301
303
|
enabled: true
|
|
304
|
+
dbUser: 'postgres'
|
|
305
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-dev'
|
|
306
|
+
proxyCredentials: '$CL_dev_app_cloudsqlProxyCredentials'
|
|
307
|
+
fullDbName: 'app'
|
|
302
308
|
projectId: 'some-project-id'
|
|
303
309
|
jobs:
|
|
304
310
|
db-migrate:
|
|
@@ -403,8 +409,11 @@ application:
|
|
|
403
409
|
enabled: true
|
|
404
410
|
command: 'launcher bundle exec rake jobs:work'
|
|
405
411
|
cloudsql:
|
|
406
|
-
proxyCredentials: '$CL_dev_app_cloudsqlProxyCredentials'
|
|
407
412
|
enabled: true
|
|
413
|
+
dbUser: 'postgres'
|
|
414
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-dev'
|
|
415
|
+
proxyCredentials: '$CL_dev_app_cloudsqlProxyCredentials'
|
|
416
|
+
fullDbName: 'app'
|
|
408
417
|
projectId: 'some-project-id'
|
|
409
418
|
jobs:
|
|
410
419
|
db-migrate:
|
|
@@ -630,8 +639,11 @@ application:
|
|
|
630
639
|
enabled: true
|
|
631
640
|
command: 'launcher bundle exec rake jobs:work'
|
|
632
641
|
cloudsql:
|
|
633
|
-
proxyCredentials: '$CL_review_app_cloudsqlProxyCredentials'
|
|
634
642
|
enabled: true
|
|
643
|
+
dbUser: 'postgres'
|
|
644
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-review'
|
|
645
|
+
proxyCredentials: '$CL_review_app_cloudsqlProxyCredentials'
|
|
646
|
+
fullDbName: 'mr1234-app'
|
|
635
647
|
projectId: 'some-project-id'
|
|
636
648
|
jobs:
|
|
637
649
|
db-migrate:
|
|
@@ -841,8 +853,11 @@ application:
|
|
|
841
853
|
enabled: true
|
|
842
854
|
command: 'launcher bundle exec rake jobs:work'
|
|
843
855
|
cloudsql:
|
|
844
|
-
proxyCredentials: '$CL_review_app_cloudsqlProxyCredentials'
|
|
845
856
|
enabled: true
|
|
857
|
+
dbUser: 'postgres'
|
|
858
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-review'
|
|
859
|
+
proxyCredentials: '$CL_review_app_cloudsqlProxyCredentials'
|
|
860
|
+
fullDbName: 'mr1234-app'
|
|
846
861
|
projectId: 'some-project-id'
|
|
847
862
|
jobs:
|
|
848
863
|
db-migrate:
|
|
@@ -950,8 +965,11 @@ application:
|
|
|
950
965
|
enabled: true
|
|
951
966
|
command: 'launcher bundle exec rake jobs:work'
|
|
952
967
|
cloudsql:
|
|
953
|
-
proxyCredentials: '$CL_review_app_cloudsqlProxyCredentials'
|
|
954
968
|
enabled: true
|
|
969
|
+
dbUser: 'postgres'
|
|
970
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-review'
|
|
971
|
+
proxyCredentials: '$CL_review_app_cloudsqlProxyCredentials'
|
|
972
|
+
fullDbName: 'mr1234-app'
|
|
955
973
|
projectId: 'some-project-id'
|
|
956
974
|
jobs:
|
|
957
975
|
db-migrate:
|
|
@@ -1180,8 +1198,11 @@ application:
|
|
|
1180
1198
|
enabled: true
|
|
1181
1199
|
command: 'launcher bundle exec rake jobs:work'
|
|
1182
1200
|
cloudsql:
|
|
1183
|
-
proxyCredentials: '$CL_prod_app_cloudsqlProxyCredentials'
|
|
1184
1201
|
enabled: true
|
|
1202
|
+
dbUser: 'postgres'
|
|
1203
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-prod'
|
|
1204
|
+
proxyCredentials: '$CL_prod_app_cloudsqlProxyCredentials'
|
|
1205
|
+
fullDbName: 'app'
|
|
1185
1206
|
projectId: 'some-project-id'
|
|
1186
1207
|
jobs:
|
|
1187
1208
|
db-migrate:
|
|
@@ -1281,8 +1302,11 @@ application:
|
|
|
1281
1302
|
enabled: true
|
|
1282
1303
|
command: 'launcher bundle exec rake jobs:work'
|
|
1283
1304
|
cloudsql:
|
|
1284
|
-
proxyCredentials: '$CL_stage_app_cloudsqlProxyCredentials'
|
|
1285
1305
|
enabled: true
|
|
1306
|
+
dbUser: 'postgres'
|
|
1307
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-stage'
|
|
1308
|
+
proxyCredentials: '$CL_stage_app_cloudsqlProxyCredentials'
|
|
1309
|
+
fullDbName: 'app'
|
|
1286
1310
|
projectId: 'some-project-id'
|
|
1287
1311
|
jobs:
|
|
1288
1312
|
db-migrate:
|
|
@@ -1495,8 +1519,11 @@ application:
|
|
|
1495
1519
|
enabled: true
|
|
1496
1520
|
command: 'launcher bundle exec rake jobs:work'
|
|
1497
1521
|
cloudsql:
|
|
1498
|
-
proxyCredentials: '$CL_prod_app_cloudsqlProxyCredentials'
|
|
1499
1522
|
enabled: true
|
|
1523
|
+
dbUser: 'postgres'
|
|
1524
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-prod'
|
|
1525
|
+
proxyCredentials: '$CL_prod_app_cloudsqlProxyCredentials'
|
|
1526
|
+
fullDbName: 'app'
|
|
1500
1527
|
projectId: 'some-project-id'
|
|
1501
1528
|
jobs:
|
|
1502
1529
|
db-migrate:
|
|
@@ -1609,8 +1636,11 @@ application:
|
|
|
1609
1636
|
enabled: true
|
|
1610
1637
|
command: 'launcher bundle exec rake jobs:work'
|
|
1611
1638
|
cloudsql:
|
|
1612
|
-
proxyCredentials: '$CL_stage_app_cloudsqlProxyCredentials'
|
|
1613
1639
|
enabled: true
|
|
1640
|
+
dbUser: 'postgres'
|
|
1641
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-stage'
|
|
1642
|
+
proxyCredentials: '$CL_stage_app_cloudsqlProxyCredentials'
|
|
1643
|
+
fullDbName: 'app'
|
|
1614
1644
|
projectId: 'some-project-id'
|
|
1615
1645
|
jobs:
|
|
1616
1646
|
db-migrate:
|
|
@@ -1715,8 +1745,11 @@ application:
|
|
|
1715
1745
|
enabled: true
|
|
1716
1746
|
command: 'launcher bundle exec rake jobs:work'
|
|
1717
1747
|
cloudsql:
|
|
1718
|
-
proxyCredentials: '$CL_prod_app_cloudsqlProxyCredentials'
|
|
1719
1748
|
enabled: true
|
|
1749
|
+
dbUser: 'postgres'
|
|
1750
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-prod'
|
|
1751
|
+
proxyCredentials: '$CL_prod_app_cloudsqlProxyCredentials'
|
|
1752
|
+
fullDbName: 'app'
|
|
1720
1753
|
projectId: 'some-project-id'
|
|
1721
1754
|
jobs:
|
|
1722
1755
|
db-migrate:
|
|
@@ -1821,8 +1854,11 @@ application:
|
|
|
1821
1854
|
enabled: true
|
|
1822
1855
|
command: 'launcher bundle exec rake jobs:work'
|
|
1823
1856
|
cloudsql:
|
|
1824
|
-
proxyCredentials: '$CL_stage_app_cloudsqlProxyCredentials'
|
|
1825
1857
|
enabled: true
|
|
1858
|
+
dbUser: 'postgres'
|
|
1859
|
+
instanceConnectionName: 'some-project-id:europe-west6:pan-test-app-stage'
|
|
1860
|
+
proxyCredentials: '$CL_stage_app_cloudsqlProxyCredentials'
|
|
1861
|
+
fullDbName: 'app'
|
|
1826
1862
|
projectId: 'some-project-id'
|
|
1827
1863
|
jobs:
|
|
1828
1864
|
db-migrate:
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
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: "kubernetes",
|
|
14
|
+
cluster: {
|
|
15
|
+
name: "some-cluster-name",
|
|
16
|
+
region: "europe-west6",
|
|
17
|
+
projectId: "some-project-id",
|
|
18
|
+
type: "gcloud",
|
|
19
|
+
domainCanonical: "panter.cloud",
|
|
20
|
+
},
|
|
21
|
+
values: {
|
|
22
|
+
cloudsql: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
it("matches snapshot", async () => {
|
|
32
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
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: "kubernetes",
|
|
14
|
+
cluster: {
|
|
15
|
+
name: "some-cluster-name",
|
|
16
|
+
region: "europe-west6",
|
|
17
|
+
projectId: "some-project-id",
|
|
18
|
+
type: "gcloud",
|
|
19
|
+
domainCanonical: "panter.cloud",
|
|
20
|
+
},
|
|
21
|
+
values: {
|
|
22
|
+
cloudsql: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
type: "unmanaged",
|
|
25
|
+
instanceConnectionName: "myproject:europe-west6:instance-name",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
it("matches snapshot", async () => {
|
|
34
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
35
|
+
});
|
package/package.json
CHANGED
package/src/build/docker.ts
CHANGED
|
@@ -45,20 +45,24 @@ export const requiresDockerBuild = (context: Context) => {
|
|
|
45
45
|
return false;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const getDockerBaseVariables = () => ({
|
|
49
|
+
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
50
|
+
DOCKER_TLS_CERTDIR: "",
|
|
51
|
+
DOCKER_DRIVER: "overlay2",
|
|
52
|
+
DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
53
|
+
});
|
|
54
|
+
|
|
48
55
|
export const getDockerBuildVariables = (context: Context) => {
|
|
49
56
|
return {
|
|
50
57
|
...DOCKER_RUNNER_BUILD_VARIABLES,
|
|
51
|
-
DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
52
58
|
DOCKERFILE_ADDITIONS:
|
|
53
59
|
context.componentConfig.build.docker?.additionsBegin?.join("\n"),
|
|
54
60
|
DOCKERFILE_ADDITIONS_END:
|
|
55
61
|
context.componentConfig.build.docker?.additionsEnd?.join("\n"),
|
|
56
62
|
APP_DIR: context.componentConfig.dir,
|
|
57
|
-
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
58
|
-
DOCKER_TLS_CERTDIR: "",
|
|
59
|
-
DOCKER_DIR: ".", // relative to componentdir
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
DOCKER_DIR: ".", // relative to componentdir
|
|
65
|
+
...getDockerBaseVariables(),
|
|
62
66
|
|
|
63
67
|
...getDockerImageVariables(context),
|
|
64
68
|
};
|
|
@@ -74,7 +78,7 @@ export const getDockerJobBaseProps = (context: Context) => {
|
|
|
74
78
|
command: ["--tls=false"],
|
|
75
79
|
},
|
|
76
80
|
],
|
|
77
|
-
variables:
|
|
81
|
+
variables: getDockerBaseVariables(),
|
|
78
82
|
};
|
|
79
83
|
};
|
|
80
84
|
export const createDockerBuildJobBase = (
|
|
@@ -89,6 +93,9 @@ export const createDockerBuildJobBase = (
|
|
|
89
93
|
...getDockerJobBaseProps(context),
|
|
90
94
|
script: script || [],
|
|
91
95
|
},
|
|
96
|
+
{
|
|
97
|
+
variables: getDockerBuildVariables(context),
|
|
98
|
+
},
|
|
92
99
|
def
|
|
93
100
|
);
|
|
94
101
|
};
|
package/src/build/index.ts
CHANGED
package/src/build/node/cache.ts
CHANGED
|
@@ -31,8 +31,8 @@ export const getNodeModulesCache = (
|
|
|
31
31
|
const componentIsInWorkspace =
|
|
32
32
|
context.packageManagerInfo?.componentIsInWorkspace;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
|
|
35
|
+
// It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
|
|
36
36
|
return [
|
|
37
37
|
{
|
|
38
38
|
// if component is in a shared workspace, use workspace cache. use individual cache else
|
package/src/build/rails/build.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { CatladderJob } from "../../types/jobs";
|
|
|
4
4
|
import { createDockerBuildJobBase, gitlabDockerLogin } from "../docker";
|
|
5
5
|
|
|
6
6
|
export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
|
|
7
|
-
const buildConfig = context.componentConfig.build
|
|
7
|
+
const buildConfig = context.componentConfig.build;
|
|
8
8
|
if (!isOfBuildType(buildConfig, "rails")) {
|
|
9
9
|
// should not happen
|
|
10
10
|
throw new Error("build type is not rails");
|
|
@@ -12,10 +12,9 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
12
12
|
|
|
13
13
|
const cnbConf = buildConfig.cnbBuilder;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
?? Object.entries(cnbConf?.buildVars ?? {}).map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
|
|
15
|
+
const packEnvArgs = Object.entries(cnbConf?.buildVars ?? {})
|
|
16
|
+
.map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
|
|
17
|
+
.join(" ");
|
|
19
18
|
|
|
20
19
|
return [
|
|
21
20
|
createDockerBuildJobBase(context, {
|
|
@@ -28,7 +27,11 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
28
27
|
`chmod +x /usr/local/bin/pack`,
|
|
29
28
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
30
29
|
`sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock`,
|
|
31
|
-
`pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${
|
|
30
|
+
`pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${
|
|
31
|
+
cnbConf?.image
|
|
32
|
+
}' --publish --cache-image "$DOCKER_CACHE_IMAGE" ${packEnvArgs} ${
|
|
33
|
+
cnbConf?.packExtraArgs?.join(" ") ?? ""
|
|
34
|
+
}`,
|
|
32
35
|
],
|
|
33
36
|
}),
|
|
34
37
|
];
|
package/src/build/rails/test.ts
CHANGED
|
@@ -17,66 +17,70 @@ export const createRailsTestJobs = (context: Context): CatladderJob[] => {
|
|
|
17
17
|
envMode: "none",
|
|
18
18
|
};
|
|
19
19
|
const defaultImage = "docker.io/ruby";
|
|
20
|
-
const bundlerCacheDir = "tmp/cache"
|
|
20
|
+
const bundlerCacheDir = "tmp/cache";
|
|
21
21
|
const bundlerInstall = [
|
|
22
22
|
`bundle config set path '${bundlerCacheDir}'`,
|
|
23
|
-
"bundle install -j $(nproc)"
|
|
24
|
-
]
|
|
23
|
+
"bundle install -j $(nproc)",
|
|
24
|
+
];
|
|
25
25
|
const bundlerCache = {
|
|
26
26
|
key: {
|
|
27
27
|
files: ["Gemfile.lock"],
|
|
28
|
-
prefix: "$CI_JOB_IMAGE" // a changed image might have different OS libraries which no longer work with the cached gems
|
|
28
|
+
prefix: "$CI_JOB_IMAGE", // a changed image might have different OS libraries which no longer work with the cached gems
|
|
29
29
|
},
|
|
30
|
-
paths: [bundlerCacheDir]
|
|
31
|
-
}
|
|
30
|
+
paths: [bundlerCacheDir],
|
|
31
|
+
};
|
|
32
32
|
const auditJob: CatladderJob | null =
|
|
33
33
|
buildConfig.audit !== false
|
|
34
34
|
? {
|
|
35
|
-
|
|
35
|
+
name: "🛡 audit",
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
...base,
|
|
38
|
+
cache: undefined, // audit does not need bundle install and no cache
|
|
39
|
+
image: buildConfig.audit?.jobImage ?? defaultImage,
|
|
40
|
+
script: [
|
|
41
|
+
`cd ${context.componentConfig.dir}`,
|
|
42
|
+
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
43
|
+
"gem install bundler-audit",
|
|
44
|
+
"bundle audit check",
|
|
45
|
+
]),
|
|
46
|
+
],
|
|
47
|
+
allow_failure: true,
|
|
48
|
+
}
|
|
49
49
|
: null;
|
|
50
50
|
|
|
51
51
|
const lintJob: CatladderJob | null =
|
|
52
52
|
buildConfig.lint !== false
|
|
53
53
|
? {
|
|
54
|
-
|
|
54
|
+
name: "👮 lint",
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
...base,
|
|
57
|
+
cache: bundlerCache,
|
|
58
|
+
image: buildConfig.lint?.jobImage ?? defaultImage,
|
|
59
|
+
script: [
|
|
60
|
+
`cd ${context.componentConfig.dir}`,
|
|
61
|
+
...bundlerInstall,
|
|
62
|
+
...(ensureArray(buildConfig.lint?.command) ?? [
|
|
63
|
+
"bundle exec rubocop",
|
|
64
|
+
]),
|
|
65
|
+
],
|
|
66
|
+
}
|
|
65
67
|
: null;
|
|
66
68
|
const testJob: CatladderJob | null =
|
|
67
69
|
buildConfig.test !== false
|
|
68
70
|
? {
|
|
69
|
-
|
|
71
|
+
name: "🧪 test",
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
...base,
|
|
74
|
+
cache: bundlerCache,
|
|
75
|
+
image: buildConfig.test?.jobImage ?? defaultImage,
|
|
76
|
+
script: [
|
|
77
|
+
`cd ${context.componentConfig.dir}`,
|
|
78
|
+
...bundlerInstall,
|
|
79
|
+
...(ensureArray(buildConfig.test?.command) ?? [
|
|
80
|
+
"bundle exec rspec",
|
|
81
|
+
]),
|
|
82
|
+
],
|
|
83
|
+
}
|
|
80
84
|
: null;
|
|
81
85
|
return [auditJob, lintJob, testJob].filter(notNil);
|
|
82
86
|
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
EnvType,
|
|
4
|
-
PipelineTrigger} from "../types";
|
|
5
|
-
import {
|
|
6
|
-
DEFAULT_ENV_TYPES,
|
|
7
|
-
getEnvTypesByTrigger
|
|
8
|
-
} from "../types";
|
|
1
|
+
import type { Config, EnvType, PipelineTrigger } from "../types";
|
|
2
|
+
import { DEFAULT_ENV_TYPES, getEnvTypesByTrigger } from "../types";
|
|
9
3
|
|
|
10
4
|
const getConfiguredAndDefaultEnvs = (
|
|
11
5
|
config: Config,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { DeployTypeDefinition } from "..";
|
|
2
2
|
import { getSecretVarName } from "../../context";
|
|
3
|
-
import { sanitizeForBashVariable } from "../../utils/gitlab";
|
|
4
3
|
import type { EnvironmentContext } from "../../types/environmentContext";
|
|
4
|
+
import { sanitizeForBashVariable } from "../../utils/gitlab";
|
|
5
|
+
import { getFullDbName } from "../cloudSql/utils";
|
|
5
6
|
import { createGoogleCloudRunDeployJobs } from "./deployJob";
|
|
6
7
|
import { getCloudRunJobName } from "./utils/jobName";
|
|
7
8
|
|
|
@@ -18,14 +19,12 @@ const getCloudSqlVariables = ({
|
|
|
18
19
|
fullConfig,
|
|
19
20
|
}: EnvironmentContext<any, "google-cloudrun">) => {
|
|
20
21
|
if (deployConfigRaw && deployConfigRaw.cloudSql) {
|
|
21
|
-
const DB_NAME =
|
|
22
|
-
deployConfigRaw.cloudSql
|
|
23
|
-
|
|
22
|
+
const DB_NAME = getFullDbName(
|
|
23
|
+
deployConfigRaw.cloudSql,
|
|
24
|
+
fullConfig,
|
|
24
25
|
environmentSlugPrefix,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.filter(Boolean)
|
|
28
|
-
.join("-");
|
|
26
|
+
componentName
|
|
27
|
+
);
|
|
29
28
|
|
|
30
29
|
const additionalQueryParamsString = Object.entries(
|
|
31
30
|
deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Config } from "../..";
|
|
2
|
+
import type {
|
|
3
|
+
DeployConfigCloudRunCloudSql,
|
|
4
|
+
DeployConfigKubernetesValuesCloudSQLUnmanaged,
|
|
5
|
+
} from "../types";
|
|
6
|
+
|
|
7
|
+
export const getFullDbName = (
|
|
8
|
+
cloudSqlConfig:
|
|
9
|
+
| DeployConfigCloudRunCloudSql
|
|
10
|
+
| DeployConfigKubernetesValuesCloudSQLUnmanaged,
|
|
11
|
+
fullConfig: Config<never>,
|
|
12
|
+
environmentSlugPrefix: string,
|
|
13
|
+
componentName: string
|
|
14
|
+
) => {
|
|
15
|
+
return [
|
|
16
|
+
cloudSqlConfig.dbNamePrefix ??
|
|
17
|
+
`${fullConfig.customerName}-${fullConfig.appName}`,
|
|
18
|
+
environmentSlugPrefix,
|
|
19
|
+
cloudSqlConfig.dbBaseName ?? componentName,
|
|
20
|
+
]
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join("-");
|
|
23
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSecretVarNameForContext } from "../../../context";
|
|
2
2
|
import type { Context } from "../../../types";
|
|
3
|
+
import { getFullDbName } from "../../cloudSql/utils";
|
|
3
4
|
import { isOfDeployType } from "../../types";
|
|
4
5
|
|
|
5
6
|
export const hasKubernetesCloudSQL = (context: Context) => {
|
|
@@ -9,20 +10,63 @@ export const hasKubernetesCloudSQL = (context: Context) => {
|
|
|
9
10
|
return false;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
type CloudSqlValues = {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
proxyCredentials: string;
|
|
16
|
+
|
|
17
|
+
instanceConnectionName: string;
|
|
18
|
+
fullDbName: string;
|
|
19
|
+
dbUser: string;
|
|
17
20
|
};
|
|
21
|
+
export const createKubernetesCloudsqlBaseValues = (
|
|
22
|
+
context: Context
|
|
23
|
+
): {
|
|
24
|
+
cloudsql: CloudSqlValues;
|
|
25
|
+
} => {
|
|
26
|
+
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
27
|
+
throw new Error("cannot get cloud sql config");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const config = context.componentConfig.deploy.values?.cloudsql;
|
|
18
31
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
if (!config) {
|
|
33
|
+
throw new Error("cannot get cloud sql config");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const proxyCredentials = `$${getSecretVarNameForContext(
|
|
37
|
+
context,
|
|
38
|
+
"cloudsqlProxyCredentials"
|
|
39
|
+
)}`;
|
|
40
|
+
if (config?.type !== "unmanaged") {
|
|
41
|
+
const instanceConnectionName = `${config.projectId ?? "skynet-164509"}:${
|
|
42
|
+
config.region ?? "europe-west6"
|
|
43
|
+
}:${config.instanceId ?? context.environment.envVars.KUBE_NAMESPACE}`;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
cloudsql: {
|
|
47
|
+
enabled: config.enabled,
|
|
48
|
+
dbUser: "postgres",
|
|
49
|
+
instanceConnectionName,
|
|
50
|
+
proxyCredentials,
|
|
51
|
+
fullDbName: context.environment.envVars.KUBE_APP_NAME,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
} else if (config.type === "unmanaged") {
|
|
55
|
+
return {
|
|
56
|
+
cloudsql: {
|
|
57
|
+
enabled: config.enabled,
|
|
58
|
+
dbUser: config.dbUser ?? "postgres",
|
|
59
|
+
instanceConnectionName: config.instanceConnectionName,
|
|
60
|
+
proxyCredentials,
|
|
61
|
+
fullDbName: getFullDbName(
|
|
62
|
+
config,
|
|
63
|
+
context.fullConfig,
|
|
64
|
+
context.environment.slugPrefix,
|
|
65
|
+
context.componentName
|
|
66
|
+
),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error("unknonw type");
|
|
71
|
+
}
|
|
28
72
|
};
|
|
@@ -40,7 +40,8 @@ export const createKubernetesDeployJobs = (
|
|
|
40
40
|
quotingType: "'",
|
|
41
41
|
forceQuotes: true,
|
|
42
42
|
}),
|
|
43
|
-
HELM_GITLAB_CHART_NAME:
|
|
43
|
+
HELM_GITLAB_CHART_NAME:
|
|
44
|
+
deployConfig.chartName ?? "/helm-charts/the-panter-chart",
|
|
44
45
|
HELM_ARGS: [
|
|
45
46
|
...(deployConfig.debug ? ["--debug"] : []),
|
|
46
47
|
...(deployConfig.additionalHelmArgs ?? []),
|
|
@@ -4,7 +4,10 @@ import type { Context } from "../../types/context";
|
|
|
4
4
|
import { mergeWithMergingArrays } from "../../utils";
|
|
5
5
|
import type { DeployConfigKubernetesValues } from "../types";
|
|
6
6
|
import { isOfDeployType } from "../types";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
hasKubernetesCloudSQL,
|
|
9
|
+
createKubernetesCloudsqlBaseValues,
|
|
10
|
+
} from "./cloudSql";
|
|
8
11
|
|
|
9
12
|
import { createKubeEnv } from "./kubeEnv";
|
|
10
13
|
import { createMongodbBaseConfig } from "./mongodb";
|
|
@@ -77,7 +80,9 @@ export const createKubeValues = (context: Context) => {
|
|
|
77
80
|
env,
|
|
78
81
|
application: createAppConfig(context, application),
|
|
79
82
|
},
|
|
80
|
-
hasKubernetesCloudSQL(context)
|
|
83
|
+
hasKubernetesCloudSQL(context)
|
|
84
|
+
? createKubernetesCloudsqlBaseValues(context)
|
|
85
|
+
: {},
|
|
81
86
|
deployConfig.values?.mongodb?.enabled
|
|
82
87
|
? createMongodbBaseConfig(context)
|
|
83
88
|
: {}
|