@catladder/pipeline 0.0.0-refactor-docker-9fda97e9 → 0.0.0-refactor-docker-c24f8608
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/base/createAppBuildJob.d.ts +2 -2
- package/dist/build/base/createAppBuildJob.js +1 -1
- package/dist/build/base/index.d.ts +2 -2
- package/dist/build/base/writeBuildInfo.d.ts +2 -2
- package/dist/build/base/writeDotEnv.d.ts +2 -2
- package/dist/build/custom/buildJob.d.ts +2 -2
- package/dist/build/custom/index.d.ts +2 -2
- package/dist/build/custom/testJob.d.ts +2 -2
- package/dist/build/docker.d.ts +11 -11
- package/dist/build/docker.js +6 -6
- package/dist/build/index.d.ts +2 -2
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +7 -7
- package/dist/build/node/cache.d.ts +5 -5
- package/dist/build/node/cache.js +4 -4
- package/dist/build/node/index.d.ts +4 -4
- package/dist/build/node/meteor.d.ts +2 -2
- package/dist/build/node/meteor.js +2 -2
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +6 -6
- package/dist/build/node/yarn.d.ts +4 -4
- package/dist/build/node/yarn.js +1 -1
- package/dist/build/rails/build.d.ts +2 -2
- package/dist/build/rails/index.d.ts +2 -2
- package/dist/build/rails/test.d.ts +2 -2
- package/dist/build/sbom.d.ts +2 -2
- package/dist/build/sbom.js +1 -1
- package/dist/bundles/catladder-gitlab/index.js +61 -46
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironment.d.ts +2 -2
- package/dist/context/getEnvironmentContext.d.ts +2 -2
- package/dist/context/getEnvironmentVariables.d.ts +4 -4
- package/dist/context/getEnvironmentVariables.js +1 -2
- package/dist/context/getLabels.d.ts +2 -2
- package/dist/context/index.d.ts +7 -3
- package/dist/context/index.js +12 -3
- package/dist/deploy/base/deploy.d.ts +2 -2
- package/dist/deploy/base/index.d.ts +2 -2
- package/dist/deploy/base/rollback.d.ts +2 -2
- package/dist/deploy/base/stop.d.ts +2 -2
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -7
- package/dist/deploy/cloudRun/cleanup.d.ts +2 -2
- package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +6 -6
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +3 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +1 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/index.d.ts +2 -2
- package/dist/deploy/cloudRun/utils/database.d.ts +3 -3
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -2
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -2
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +1 -1
- package/dist/deploy/dockerTag/deployJob.d.ts +2 -2
- package/dist/deploy/index.d.ts +2 -2
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -3
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeEnv.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.js +1 -3
- package/dist/deploy/kubernetes/mongodb.d.ts +2 -2
- package/dist/deploy/sbom.d.ts +4 -4
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/pipeline/createJobsForComponent.d.ts +2 -2
- package/dist/pipeline/createJobsForComponent.js +1 -1
- package/dist/pipeline/generatePipelineFiles.js +15 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/context.d.ts +16 -2
- package/dist/types/jobs.d.ts +1 -1
- package/examples/__snapshots__/cloud-run-storybook.ts.snap +1687 -0
- package/examples/__utils__/helpers.ts +2 -2
- package/examples/cloud-run-storybook.ts +24 -0
- package/package.json +1 -1
- package/scripts/generate-gitlab-ci-types.ts +2 -2
- package/src/bash/BashExpression.ts +4 -4
- package/src/bash/bashExpressionPerPipelineType.ts +1 -1
- package/src/bash/replaceAsync.ts +4 -4
- package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
- package/src/build/base/createAppBuildJob.ts +3 -3
- package/src/build/base/createArtifactsConfig.ts +2 -2
- package/src/build/base/index.ts +2 -2
- package/src/build/base/writeBuildInfo.ts +2 -2
- package/src/build/base/writeDotEnv.ts +3 -3
- package/src/build/custom/__tests__/testJob.test.ts +6 -6
- package/src/build/custom/buildJob.ts +4 -2
- package/src/build/custom/index.ts +2 -2
- package/src/build/custom/testJob.ts +7 -5
- package/src/build/docker.ts +18 -18
- package/src/build/index.ts +3 -3
- package/src/build/node/buildJob.ts +16 -10
- package/src/build/node/cache.ts +13 -13
- package/src/build/node/index.ts +6 -4
- package/src/build/node/meteor.ts +10 -5
- package/src/build/node/testJob.ts +14 -11
- package/src/build/node/yarn.ts +13 -15
- package/src/build/rails/build.ts +4 -2
- package/src/build/rails/index.ts +2 -2
- package/src/build/rails/test.ts +4 -2
- package/src/build/sbom.ts +4 -4
- package/src/config/configruedEnvs.ts +6 -6
- package/src/config/readConfig.ts +2 -2
- package/src/context/__tests__/resolveReferences.test.ts +1 -1
- package/src/context/getBuildInfoVariables.ts +5 -5
- package/src/context/getEnvConfig.ts +1 -1
- package/src/context/getEnvType.ts +1 -1
- package/src/context/getEnvironment.ts +2 -2
- package/src/context/getEnvironmentContext.ts +4 -4
- package/src/context/getEnvironmentVariables.ts +19 -16
- package/src/context/getLabels.ts +2 -2
- package/src/context/getReviewSlug.ts +2 -2
- package/src/context/index.ts +17 -7
- package/src/context/resolveReferences.ts +12 -9
- package/src/context/transformJobOnlyVars.ts +1 -1
- package/src/context/utils/envVars.ts +3 -3
- package/src/deploy/base/deploy.ts +7 -7
- package/src/deploy/base/index.ts +3 -3
- package/src/deploy/base/rollback.ts +3 -3
- package/src/deploy/base/stop.ts +3 -3
- package/src/deploy/cloudRun/artifactsRegistry.ts +17 -12
- package/src/deploy/cloudRun/cleanup.ts +5 -5
- package/src/deploy/cloudRun/cloudRunRevisions.ts +6 -6
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +20 -20
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -7
- package/src/deploy/cloudRun/createJobs/common.ts +5 -5
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +12 -9
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +3 -3
- package/src/deploy/cloudRun/createJobs/index.ts +2 -2
- package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
- package/src/deploy/cloudRun/index.ts +10 -6
- package/src/deploy/cloudRun/utils/createArgsString.ts +1 -1
- package/src/deploy/cloudRun/utils/database.ts +8 -8
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +5 -3
- package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
- package/src/deploy/cloudRun/utils/jobName.ts +1 -1
- package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
- package/src/deploy/cloudSql/utils.ts +2 -2
- package/src/deploy/custom/deployJob.ts +7 -3
- package/src/deploy/dockerTag/deployJob.ts +4 -2
- package/src/deploy/index.ts +5 -5
- package/src/deploy/kubernetes/cloudSql/index.ts +5 -5
- package/src/deploy/kubernetes/deployJob.ts +7 -7
- package/src/deploy/kubernetes/index.ts +1 -1
- package/src/deploy/kubernetes/kubeEnv.ts +3 -3
- package/src/deploy/kubernetes/kubeValues.ts +8 -8
- package/src/deploy/kubernetes/mongodb.ts +9 -9
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +3 -3
- package/src/deploy/sbom.ts +8 -4
- package/src/deploy/utils.ts +4 -4
- package/src/pipeline/createAllJobs.ts +4 -4
- package/src/pipeline/createChildPipeline.ts +2 -2
- package/src/pipeline/createJobsForComponent.ts +13 -9
- package/src/pipeline/createMainPipeline.ts +20 -17
- package/src/pipeline/generatePipelineFiles.ts +21 -12
- package/src/pipeline/getPipelineStages.ts +1 -1
- package/src/pipeline/gitlab/createGitlabJobs.ts +26 -26
- package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +6 -6
- package/src/pipeline/packageManager.ts +2 -2
- package/src/pipeline/yarn/yarnUtils.ts +7 -7
- package/src/types/config.ts +4 -4
- package/src/types/context.ts +19 -3
- package/src/types/environmentContext.ts +1 -1
- package/src/types/jobs.ts +1 -1
- package/src/types/utils.ts +4 -4
- package/src/utils/gitlab.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/writeFiles.ts +2 -2
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { isNil, omit } from "lodash";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
ComponentContext,
|
|
4
|
+
UnspecifiedEnvVars,
|
|
5
|
+
} from "../../../types/context";
|
|
3
6
|
import { collapseableSection } from "../../../utils/gitlab";
|
|
4
7
|
import { getDependencyTrackUploadScript } from "../../sbom";
|
|
5
8
|
|
|
@@ -25,29 +28,29 @@ import {
|
|
|
25
28
|
yamlBashString,
|
|
26
29
|
} from "../../../bash/bashYaml";
|
|
27
30
|
|
|
28
|
-
export function getCloudRunDeployScripts(context:
|
|
31
|
+
export function getCloudRunDeployScripts(context: ComponentContext) {
|
|
29
32
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
30
33
|
const allEnvVars = omit(
|
|
31
34
|
context.environment.envVars,
|
|
32
|
-
GCLOUD_DEPLOY_CREDENTIALS_KEY
|
|
35
|
+
GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
33
36
|
);
|
|
34
37
|
|
|
35
38
|
return [
|
|
36
39
|
...collapseableSection(
|
|
37
40
|
"prepare",
|
|
38
|
-
"Prepare..."
|
|
41
|
+
"Prepare...",
|
|
39
42
|
)([
|
|
40
43
|
...gcloudServiceAccountLoginCommands(context),
|
|
41
44
|
...setGoogleProjectNumberScript(deployConfig),
|
|
42
45
|
]),
|
|
43
46
|
...collapseableSection(
|
|
44
47
|
"writeenvvars",
|
|
45
|
-
"Write env vars to file"
|
|
48
|
+
"Write env vars to file",
|
|
46
49
|
)(writeBashYamlToFileScript(allEnvVars, ENV_VARS_FILENAME)),
|
|
47
50
|
|
|
48
51
|
...collapseableSection(
|
|
49
52
|
"deploy",
|
|
50
|
-
"Deploy to cloud run"
|
|
53
|
+
"Deploy to cloud run",
|
|
51
54
|
)([
|
|
52
55
|
...(deployConfig.cloudSql
|
|
53
56
|
? getDatabaseCreateScript(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
@@ -61,15 +64,15 @@ export function getCloudRunDeployScripts(context: Context) {
|
|
|
61
64
|
: []),
|
|
62
65
|
...Object.entries(deployConfig.additionalServices ?? {}).map(
|
|
63
66
|
([name, service]) =>
|
|
64
|
-
getServiceDeployScript(context, service, "-" + name)
|
|
67
|
+
getServiceDeployScript(context, service, "-" + name),
|
|
65
68
|
),
|
|
66
69
|
...getJobRunScripts(context, "postDeploy"),
|
|
67
70
|
]),
|
|
68
71
|
...collapseableSection(
|
|
69
72
|
"cleanup",
|
|
70
|
-
"Cleanup"
|
|
73
|
+
"Cleanup",
|
|
71
74
|
)(
|
|
72
|
-
getRemoveOldRevisionsAndImagesCommand(context, "postDeploy") // we cleanup inactive images both on deploy and stop
|
|
75
|
+
getRemoveOldRevisionsAndImagesCommand(context, "postDeploy"), // we cleanup inactive images both on deploy and stop
|
|
73
76
|
),
|
|
74
77
|
...getDependencyTrackUploadScript(context),
|
|
75
78
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
2
|
import { getDependencyTrackDeleteScript } from "../../sbom";
|
|
3
3
|
|
|
4
4
|
import { getRemoveOldRevisionsAndImagesCommand } from "../cleanup";
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
import { getServiceDeleteScript } from "./cloudRunServices";
|
|
13
13
|
import { getCloudRunDeployConfig } from "./common";
|
|
14
14
|
|
|
15
|
-
export function getCloudRunStopScripts(context:
|
|
15
|
+
export function getCloudRunStopScripts(context: ComponentContext) {
|
|
16
16
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
17
17
|
return [
|
|
18
18
|
...gcloudServiceAccountLoginCommands(context),
|
|
19
19
|
...getJobRunScripts(context, "preStop"),
|
|
20
20
|
...(deployConfig.service !== false ? getServiceDeleteScript(context) : []),
|
|
21
21
|
...Object.entries(deployConfig.additionalServices ?? {}).flatMap(([name]) =>
|
|
22
|
-
getServiceDeleteScript(context, name)
|
|
22
|
+
getServiceDeleteScript(context, name),
|
|
23
23
|
),
|
|
24
24
|
...getJobRunScripts(context, "postStop"),
|
|
25
25
|
...getDeleteSchedulesScripts(context),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getRunnerImage } from "../../../runner";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../../types/context";
|
|
3
3
|
import type { CatladderJob } from "../../../types/jobs";
|
|
4
4
|
import { allowFailureInScripts } from "../../../utils/gitlab";
|
|
5
5
|
import { createDeployementJobs } from "../../base";
|
|
@@ -10,7 +10,7 @@ import { getCloudRunDeployScripts } from "./getCloudRunDeployScripts";
|
|
|
10
10
|
import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
|
|
11
11
|
|
|
12
12
|
export const createGoogleCloudRunDeployJobs = (
|
|
13
|
-
context:
|
|
13
|
+
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
15
|
const deployConfig = context.componentConfig.deploy;
|
|
16
16
|
if (deployConfig === false) {
|
|
@@ -3,7 +3,7 @@ import type { keyValuesArg } from "../utils/createArgsString";
|
|
|
3
3
|
|
|
4
4
|
export const createVolumeConfig = (
|
|
5
5
|
volumes: DeployConfigCloudRunVolumes | undefined,
|
|
6
|
-
type: "service" | "job"
|
|
6
|
+
type: "service" | "job",
|
|
7
7
|
): keyValuesArg[] => {
|
|
8
8
|
if (!volumes) {
|
|
9
9
|
return [];
|
|
@@ -16,7 +16,7 @@ export const createVolumeConfig = (
|
|
|
16
16
|
readonly ? ",readonly=true" : ""
|
|
17
17
|
}`,
|
|
18
18
|
"add-volume-mount": `volume=${volumeName},mount-path=${mountPath}`,
|
|
19
|
-
})
|
|
19
|
+
}),
|
|
20
20
|
),
|
|
21
21
|
type === "service" ? { "execution-environment": "gen2" } : {},
|
|
22
22
|
];
|
|
@@ -33,11 +33,11 @@ const getCloudSqlVariables = ({
|
|
|
33
33
|
deployConfigRaw.cloudSql,
|
|
34
34
|
fullConfig,
|
|
35
35
|
environmentSlugPrefix,
|
|
36
|
-
componentName
|
|
36
|
+
componentName,
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
const additionalQueryParamsString = Object.entries(
|
|
40
|
-
deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {}
|
|
40
|
+
deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {},
|
|
41
41
|
)
|
|
42
42
|
.map(([key, value]) => `&${key}=${value}`)
|
|
43
43
|
.join("");
|
|
@@ -49,7 +49,7 @@ const getCloudSqlVariables = ({
|
|
|
49
49
|
DB_USER: deployConfigRaw.cloudSql.dbUser ?? "postgres",
|
|
50
50
|
DB_PASSWORD: "$" + getSecretVarName(env, componentName, "DB_PASSWORD"),
|
|
51
51
|
DATABASE_URL: `${getDatabaseConnectionString(
|
|
52
|
-
deployConfigRaw.cloudSql
|
|
52
|
+
deployConfigRaw.cloudSql,
|
|
53
53
|
)}${additionalQueryParamsString}`,
|
|
54
54
|
DATABASE_JDBC_URL: DATABASE_JDBC_URL,
|
|
55
55
|
};
|
|
@@ -88,10 +88,14 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
|
|
|
88
88
|
[
|
|
89
89
|
fullName,
|
|
90
90
|
getBashVariable(
|
|
91
|
-
getSecretVarName(
|
|
91
|
+
getSecretVarName(
|
|
92
|
+
env,
|
|
93
|
+
componentName,
|
|
94
|
+
GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
95
|
+
),
|
|
92
96
|
),
|
|
93
97
|
],
|
|
94
|
-
"-"
|
|
98
|
+
"-",
|
|
95
99
|
).toLowerCase();
|
|
96
100
|
const jobTriggers =
|
|
97
101
|
deployConfigRaw && deployConfigRaw.jobs
|
|
@@ -103,7 +107,7 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
|
|
|
103
107
|
}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${
|
|
104
108
|
deployConfigRaw.projectId
|
|
105
109
|
}/jobs/${getCloudRunJobName(fullName, name)}:run`,
|
|
106
|
-
])
|
|
110
|
+
]),
|
|
107
111
|
)
|
|
108
112
|
: {};
|
|
109
113
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../../types";
|
|
2
2
|
import { allowFailureInScripts, repeatOnFailure } from "../../../utils/gitlab";
|
|
3
3
|
import type {
|
|
4
4
|
DeployConfigCloudRun,
|
|
@@ -6,8 +6,8 @@ import type {
|
|
|
6
6
|
} from "../../types";
|
|
7
7
|
|
|
8
8
|
export const getDatabaseDeleteScript = (
|
|
9
|
-
context:
|
|
10
|
-
deployConfig: DeployConfigCloudRun
|
|
9
|
+
context: ComponentContext,
|
|
10
|
+
deployConfig: DeployConfigCloudRun,
|
|
11
11
|
): string[] => {
|
|
12
12
|
if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
|
|
13
13
|
throw new Error("not possible");
|
|
@@ -29,14 +29,14 @@ export const getDatabaseDeleteScript = (
|
|
|
29
29
|
`gcloud sql databases delete ${DB_NAME} --instance=${instanceId} --project ${projectId}`,
|
|
30
30
|
{
|
|
31
31
|
pauseInSeconds: 10,
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
),
|
|
34
34
|
];
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export const getDatabaseCreateScript = (
|
|
38
|
-
context:
|
|
39
|
-
deployConfig: DeployConfigCloudRun
|
|
38
|
+
context: ComponentContext,
|
|
39
|
+
deployConfig: DeployConfigCloudRun,
|
|
40
40
|
): string[] => {
|
|
41
41
|
if (!deployConfig.cloudSql) {
|
|
42
42
|
throw new Error("not possible");
|
|
@@ -61,14 +61,14 @@ export const DATABASE_JDBC_URL =
|
|
|
61
61
|
"jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD";
|
|
62
62
|
|
|
63
63
|
export const getDatabaseConnectionString = (
|
|
64
|
-
config: DeployConfigCloudRunCloudSql
|
|
64
|
+
config: DeployConfigCloudRunCloudSql,
|
|
65
65
|
): string => {
|
|
66
66
|
switch (config.dbConnectionStringFormat) {
|
|
67
67
|
case "jdbc":
|
|
68
68
|
return DATABASE_JDBC_URL;
|
|
69
69
|
case "rails":
|
|
70
70
|
return `postgresql://$DB_USER:$DB_PASSWORD@${encodeURIComponent(
|
|
71
|
-
`/cloudsql/${config.instanceConnectionName}
|
|
71
|
+
`/cloudsql/${config.instanceConnectionName}`,
|
|
72
72
|
)}/$DB_NAME?`;
|
|
73
73
|
default:
|
|
74
74
|
// prisma
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from "..";
|
|
2
2
|
import { getSecretVarNameForContext } from "../../../context";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../../types";
|
|
4
4
|
|
|
5
|
-
export const gcloudServiceAccountLoginCommands = (
|
|
5
|
+
export const gcloudServiceAccountLoginCommands = (
|
|
6
|
+
context: ComponentContext,
|
|
7
|
+
) => [
|
|
6
8
|
`gcloud auth activate-service-account --key-file=<(echo "$${getSecretVarNameForContext(
|
|
7
9
|
context,
|
|
8
|
-
GCLOUD_DEPLOY_CREDENTIALS_KEY
|
|
10
|
+
GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
9
11
|
)}")`,
|
|
10
12
|
];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export const getServiceName = (context:
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
|
+
export const getServiceName = (context: ComponentContext) =>
|
|
3
3
|
context.environment.fullName.toLowerCase();
|
|
@@ -2,6 +2,6 @@ import type { StringOrBashExpression } from "../../../bash/BashExpression";
|
|
|
2
2
|
|
|
3
3
|
export const getCloudRunJobName = (
|
|
4
4
|
fullAppName: StringOrBashExpression,
|
|
5
|
-
jobName: string
|
|
5
|
+
jobName: string,
|
|
6
6
|
): StringOrBashExpression =>
|
|
7
7
|
fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
|
|
@@ -12,7 +12,7 @@ export const getFullDbName = (
|
|
|
12
12
|
| DeployConfigKubernetesValuesCloudSQLUnmanaged,
|
|
13
13
|
fullConfig: Config<never>,
|
|
14
14
|
environmentSlugPrefix: StringOrBashExpression,
|
|
15
|
-
componentName: string
|
|
15
|
+
componentName: string,
|
|
16
16
|
) => {
|
|
17
17
|
return joinBashExpressions(
|
|
18
18
|
[
|
|
@@ -21,6 +21,6 @@ export const getFullDbName = (
|
|
|
21
21
|
environmentSlugPrefix,
|
|
22
22
|
cloudSqlConfig.dbBaseName ?? componentName,
|
|
23
23
|
].flatMap((part) => (part ? [part] : [])),
|
|
24
|
-
"-"
|
|
24
|
+
"-",
|
|
25
25
|
);
|
|
26
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getYarnInstall } from "../../build/node/yarn";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { createDeployementJobs } from "../base";
|
|
6
6
|
import {
|
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
} from "../sbom";
|
|
10
10
|
import { isOfDeployType } from "../types";
|
|
11
11
|
|
|
12
|
-
export const createCustomDeployJobs = (
|
|
12
|
+
export const createCustomDeployJobs = (
|
|
13
|
+
context: ComponentContext,
|
|
14
|
+
): CatladderJob[] => {
|
|
13
15
|
const deployConfig = context.componentConfig.deploy;
|
|
14
16
|
if (deployConfig === false) {
|
|
15
17
|
return [];
|
|
@@ -19,7 +21,9 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
19
21
|
throw new Error("deploy config is not custom");
|
|
20
22
|
}
|
|
21
23
|
// FIXME: custom deploy currently assumes yarn-based project
|
|
22
|
-
const yarnInstall = getYarnInstall(context, {
|
|
24
|
+
const yarnInstall = getYarnInstall(context.buildContext, {
|
|
25
|
+
noCustomPostInstall: true,
|
|
26
|
+
});
|
|
23
27
|
return createDeployementJobs(context, {
|
|
24
28
|
deploy: {
|
|
25
29
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getDockerJobBaseProps, gitlabDockerLogin } from "../../build/docker";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { createDeployementJobs } from "../base";
|
|
6
6
|
import { isOfDeployType } from "../types";
|
|
7
7
|
|
|
8
|
-
export const createDockerTagDeployJobs = (
|
|
8
|
+
export const createDockerTagDeployJobs = (
|
|
9
|
+
context: ComponentContext,
|
|
10
|
+
): CatladderJob[] => {
|
|
9
11
|
const deployConfig = context.componentConfig.deploy;
|
|
10
12
|
if (deployConfig === false) {
|
|
11
13
|
return [];
|
package/src/deploy/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SecretEnvVar } from "..";
|
|
2
2
|
import type { BashExpression } from "../bash/BashExpression";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../types/context";
|
|
4
4
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
5
5
|
import type { CatladderJob } from "../types/jobs";
|
|
6
6
|
import type { PartialDeep } from "../types/utils";
|
|
@@ -15,15 +15,15 @@ export * from "./types";
|
|
|
15
15
|
export * from "./utils";
|
|
16
16
|
|
|
17
17
|
export type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
18
|
-
jobs: (context:
|
|
18
|
+
jobs: (context: ComponentContext) => CatladderJob[];
|
|
19
19
|
defaults: (
|
|
20
|
-
envContext: EnvironmentContext<any, T
|
|
20
|
+
envContext: EnvironmentContext<any, T>,
|
|
21
21
|
) => PartialDeep<DeployConfigGeneric<T>>;
|
|
22
22
|
additionalSecretKeys: (
|
|
23
|
-
envContext: EnvironmentContext<any, T
|
|
23
|
+
envContext: EnvironmentContext<any, T>,
|
|
24
24
|
) => SecretEnvVar[];
|
|
25
25
|
getAdditionalEnvVars: (
|
|
26
|
-
envContext: EnvironmentContext<any, T
|
|
26
|
+
envContext: EnvironmentContext<any, T>,
|
|
27
27
|
) => Record<string, string | BashExpression | undefined | null>;
|
|
28
28
|
};
|
|
29
29
|
export type DeployTypes = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { StringOrBashExpression } from "../../../bash/BashExpression";
|
|
2
2
|
import { getSecretVarNameForContext } from "../../../context";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../../types";
|
|
4
4
|
import { getFullDbName } from "../../cloudSql/utils";
|
|
5
5
|
import { isOfDeployType } from "../../types";
|
|
6
6
|
|
|
7
|
-
export const hasKubernetesCloudSQL = (context:
|
|
7
|
+
export const hasKubernetesCloudSQL = (context: ComponentContext) => {
|
|
8
8
|
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
9
9
|
return context.componentConfig.deploy.values?.cloudsql?.enabled;
|
|
10
10
|
}
|
|
@@ -20,7 +20,7 @@ type CloudSqlValues = {
|
|
|
20
20
|
dbUser: string;
|
|
21
21
|
};
|
|
22
22
|
export const createKubernetesCloudsqlBaseValues = (
|
|
23
|
-
context:
|
|
23
|
+
context: ComponentContext,
|
|
24
24
|
): {
|
|
25
25
|
cloudsql: CloudSqlValues;
|
|
26
26
|
} => {
|
|
@@ -36,7 +36,7 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
36
36
|
|
|
37
37
|
const proxyCredentials = `$${getSecretVarNameForContext(
|
|
38
38
|
context,
|
|
39
|
-
"cloudsqlProxyCredentials"
|
|
39
|
+
"cloudsqlProxyCredentials",
|
|
40
40
|
)}`;
|
|
41
41
|
if (config?.type !== "unmanaged") {
|
|
42
42
|
const instanceConnectionName = `${config.projectId ?? "skynet-164509"}:${
|
|
@@ -63,7 +63,7 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
63
63
|
config,
|
|
64
64
|
context.fullConfig,
|
|
65
65
|
context.environment.slugPrefix,
|
|
66
|
-
context.componentName
|
|
66
|
+
context.componentName,
|
|
67
67
|
),
|
|
68
68
|
},
|
|
69
69
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { createDeployementJobs } from "../base";
|
|
6
6
|
import {
|
|
@@ -15,7 +15,7 @@ import { collapseableSection } from "../../utils/gitlab";
|
|
|
15
15
|
|
|
16
16
|
const ALL_VALUES_FILE = "__all_values.yml";
|
|
17
17
|
export const createKubernetesDeployJobs = (
|
|
18
|
-
context:
|
|
18
|
+
context: ComponentContext,
|
|
19
19
|
): CatladderJob[] => {
|
|
20
20
|
const deployConfig = context.componentConfig.deploy;
|
|
21
21
|
if (deployConfig === false) {
|
|
@@ -59,14 +59,14 @@ export const createKubernetesDeployJobs = (
|
|
|
59
59
|
const connectContext = [
|
|
60
60
|
`kubectl config set-cluster "${clusterName}" --server="$${getSecretVarNameForContext(
|
|
61
61
|
context,
|
|
62
|
-
"KUBE_URL"
|
|
62
|
+
"KUBE_URL",
|
|
63
63
|
)}" --certificate-authority <(echo $${getSecretVarNameForContext(
|
|
64
64
|
context,
|
|
65
|
-
"KUBE_CA_PEM"
|
|
65
|
+
"KUBE_CA_PEM",
|
|
66
66
|
)} | base64 -d) --embed-certs=true`,
|
|
67
67
|
`kubectl config set-credentials "${clusterName}" --token="$${getSecretVarNameForContext(
|
|
68
68
|
context,
|
|
69
|
-
"KUBE_TOKEN"
|
|
69
|
+
"KUBE_TOKEN",
|
|
70
70
|
)}"`,
|
|
71
71
|
`kubectl config set-context "${clusterName}" --cluster="${clusterName}" --user="${clusterName}" --namespace="${context.environment.envVars.KUBE_NAMESPACE}"`,
|
|
72
72
|
`kubectl config use-context "${clusterName}"`,
|
|
@@ -79,9 +79,9 @@ export const createKubernetesDeployJobs = (
|
|
|
79
79
|
...connectContext,
|
|
80
80
|
...collapseableSection(
|
|
81
81
|
"writeallvalues",
|
|
82
|
-
"Write " + ALL_VALUES_FILE + " for helm deployment"
|
|
82
|
+
"Write " + ALL_VALUES_FILE + " for helm deployment",
|
|
83
83
|
)(
|
|
84
|
-
writeBashYamlToFileScript(createKubeValues(context), ALL_VALUES_FILE)
|
|
84
|
+
writeBashYamlToFileScript(createKubeValues(context), ALL_VALUES_FILE),
|
|
85
85
|
),
|
|
86
86
|
"kubernetesCreateSecret",
|
|
87
87
|
"kubernetesDeploy",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../types";
|
|
3
3
|
import { isOfDeployType } from "../types";
|
|
4
4
|
|
|
5
5
|
const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
|
|
@@ -14,7 +14,7 @@ const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
|
|
|
14
14
|
* separate by secrets and public.
|
|
15
15
|
* we evalulate the actual values later, but want to store the secrets in kubernetes secrets
|
|
16
16
|
*/
|
|
17
|
-
export const createKubeEnv = (context:
|
|
17
|
+
export const createKubeEnv = (context: ComponentContext) => {
|
|
18
18
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
19
19
|
// should not happen
|
|
20
20
|
throw new Error("deploy config is not kubernetes");
|
|
@@ -43,7 +43,7 @@ export const createKubeEnv = (context: Context) => {
|
|
|
43
43
|
{
|
|
44
44
|
secret: {},
|
|
45
45
|
public: {},
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
return env;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import { mergeWithMergingArrays } from "../../utils";
|
|
5
5
|
import type { DeployConfigKubernetesValues } from "../types";
|
|
6
6
|
import { isOfDeployType } from "../types";
|
|
@@ -14,8 +14,8 @@ import { createMongodbBaseConfig } from "./mongodb";
|
|
|
14
14
|
import { processSecretsAsFiles } from "./processSecretsAsFiles";
|
|
15
15
|
|
|
16
16
|
const createAppConfig = (
|
|
17
|
-
context:
|
|
18
|
-
application: DeployConfigKubernetesValues["application"]
|
|
17
|
+
context: ComponentContext,
|
|
18
|
+
application: DeployConfigKubernetesValues["application"],
|
|
19
19
|
): DeployConfigKubernetesValues["application"] => {
|
|
20
20
|
if (application === false) {
|
|
21
21
|
return {
|
|
@@ -45,18 +45,18 @@ const createAppConfig = (
|
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
}, // default
|
|
48
|
-
rest // merge rest in
|
|
48
|
+
rest, // merge rest in
|
|
49
49
|
);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const removeFalsy = <T>(record?: Record<string, false | T>) => {
|
|
53
53
|
if (!record) return undefined;
|
|
54
54
|
return Object.fromEntries(
|
|
55
|
-
Object.entries(record).filter(([, value]) => value !== false)
|
|
55
|
+
Object.entries(record).filter(([, value]) => value !== false),
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
export const createKubeValues = (context:
|
|
59
|
+
export const createKubeValues = (context: ComponentContext) => {
|
|
60
60
|
const deployConfig = context.componentConfig.deploy;
|
|
61
61
|
if (deployConfig === false) {
|
|
62
62
|
return [];
|
|
@@ -84,7 +84,7 @@ export const createKubeValues = (context: Context) => {
|
|
|
84
84
|
: {},
|
|
85
85
|
deployConfig.values?.mongodb?.enabled
|
|
86
86
|
? createMongodbBaseConfig(context)
|
|
87
|
-
: {}
|
|
87
|
+
: {},
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
const kubeValues = processSecretsAsFiles(
|
|
@@ -93,7 +93,7 @@ export const createKubeValues = (context: Context) => {
|
|
|
93
93
|
cronjobs: removeFalsy(cronjobs),
|
|
94
94
|
|
|
95
95
|
...rest,
|
|
96
|
-
})
|
|
96
|
+
}),
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
return kubeValues;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { range } from "lodash";
|
|
2
2
|
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import { isOfDeployType } from "../types";
|
|
5
5
|
|
|
6
|
-
const getCredentialString = (context:
|
|
6
|
+
const getCredentialString = (context: ComponentContext) =>
|
|
7
7
|
`root:$${getSecretVarNameForContext(context, "MONGODB_ROOT_PASSWORD")}@`;
|
|
8
|
-
const getMongodbHost = (context:
|
|
8
|
+
const getMongodbHost = (context: ComponentContext, name: string) => {
|
|
9
9
|
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
10
10
|
return `${name}.${namespace}.svc.cluster.local:27017`;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const getMongodbStandaloneHost = (context:
|
|
13
|
+
const getMongodbStandaloneHost = (context: ComponentContext) => {
|
|
14
14
|
const fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
15
15
|
return getMongodbHost(context, `${fullAppname}-mongodb`);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const getMongodbReplicasetHost = (context:
|
|
18
|
+
const getMongodbReplicasetHost = (context: ComponentContext, index: number) => {
|
|
19
19
|
const fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
20
20
|
return getMongodbHost(
|
|
21
21
|
context,
|
|
22
|
-
`${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless
|
|
22
|
+
`${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless`,
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
|
-
const createMongodbUrl = (context:
|
|
25
|
+
const createMongodbUrl = (context: ComponentContext, dbName: string) => {
|
|
26
26
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
27
27
|
throw new Error("can only createMongodbUrl on supported deploys");
|
|
28
28
|
}
|
|
@@ -46,7 +46,7 @@ const createMongodbUrl = (context: Context, dbName: string) => {
|
|
|
46
46
|
queryParams ? `?${queryParams}` : ""
|
|
47
47
|
}`;
|
|
48
48
|
};
|
|
49
|
-
const createMongoBackupDefaultConfig = (context:
|
|
49
|
+
const createMongoBackupDefaultConfig = (context: ComponentContext) => {
|
|
50
50
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
51
51
|
throw new Error("can only create mongodb base config on supported deploys");
|
|
52
52
|
}
|
|
@@ -83,7 +83,7 @@ const createMongoBackupDefaultConfig = (context: Context) => {
|
|
|
83
83
|
volumeSnapshotClass: "snapshotclass",
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
export const createMongodbBaseConfig = (context:
|
|
86
|
+
export const createMongodbBaseConfig = (context: ComponentContext) => {
|
|
87
87
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
88
88
|
throw new Error("can only create mongodb base config on supported deploys");
|
|
89
89
|
}
|
|
@@ -7,9 +7,9 @@ export const processSecretsAsFiles = <
|
|
|
7
7
|
env: {
|
|
8
8
|
secret: Record<string, StringOrBashExpression>;
|
|
9
9
|
};
|
|
10
|
-
} & DeployConfigKubernetesValues
|
|
10
|
+
} & DeployConfigKubernetesValues,
|
|
11
11
|
>(
|
|
12
|
-
values: T
|
|
12
|
+
values: T,
|
|
13
13
|
): T => {
|
|
14
14
|
if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
|
|
15
15
|
return values;
|
|
@@ -27,7 +27,7 @@ export const processSecretsAsFiles = <
|
|
|
27
27
|
values.secretsAsFile.map((key) => [
|
|
28
28
|
key + "_content",
|
|
29
29
|
values.env.secret[key],
|
|
30
|
-
])
|
|
30
|
+
]),
|
|
31
31
|
),
|
|
32
32
|
},
|
|
33
33
|
},
|
package/src/deploy/sbom.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../types/context";
|
|
2
2
|
import { SBOM_FILE } from "../build/sbom";
|
|
3
3
|
|
|
4
|
-
export const sbomDeactivated = (context:
|
|
4
|
+
export const sbomDeactivated = (context: ComponentContext) =>
|
|
5
5
|
context.componentConfig.build.type === "custom" &&
|
|
6
6
|
context.componentConfig.build.sbom === false;
|
|
7
7
|
|
|
8
|
-
export const getDependencyTrackUploadScript = (
|
|
8
|
+
export const getDependencyTrackUploadScript = (
|
|
9
|
+
context: ComponentContext,
|
|
10
|
+
): string[] => {
|
|
9
11
|
return sbomDeactivated(context)
|
|
10
12
|
? []
|
|
11
13
|
: [
|
|
@@ -14,7 +16,9 @@ export const getDependencyTrackUploadScript = (context: Context): string[] => {
|
|
|
14
16
|
];
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
export const getDependencyTrackDeleteScript = (
|
|
19
|
+
export const getDependencyTrackDeleteScript = (
|
|
20
|
+
context: ComponentContext,
|
|
21
|
+
): string[] => {
|
|
18
22
|
return sbomDeactivated(context)
|
|
19
23
|
? []
|
|
20
24
|
: [
|