@payfit/nx-core 0.0.0-e2e → 0.0.0-semver
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/README.md +10 -163
- package/dist/src/executors/publisher/docker.d.ts +3 -1
- package/dist/src/executors/publisher/docker.js +12 -57
- package/dist/src/executors/publisher/docker.js.map +1 -1
- package/dist/src/executors/publisher/executor.js +12 -9
- package/dist/src/executors/publisher/executor.js.map +1 -1
- package/dist/src/executors/publisher/helm.d.ts +5 -1
- package/dist/src/executors/publisher/helm.js +11 -40
- package/dist/src/executors/publisher/helm.js.map +1 -1
- package/dist/src/executors/publisher/schema.d.ts +5 -0
- package/dist/src/executors/publisher/schema.json +0 -44
- package/dist/src/index.d.ts +1 -24
- package/dist/src/index.js +11 -67
- package/dist/src/index.js.map +1 -1
- package/dist/src/scripts/version-actions.d.ts +20 -3
- package/dist/src/scripts/version-actions.js +41 -23
- package/dist/src/scripts/version-actions.js.map +1 -1
- package/dist/src/utils/{common/aws-auth.d.ts → aws-auth.d.ts} +8 -16
- package/dist/src/utils/aws-auth.js +84 -0
- package/dist/src/utils/aws-auth.js.map +1 -0
- package/dist/src/utils/docker.d.ts +16 -12
- package/dist/src/utils/docker.js +23 -63
- package/dist/src/utils/docker.js.map +1 -1
- package/dist/src/utils/exec.d.ts +7 -0
- package/dist/src/utils/exec.js +25 -0
- package/dist/src/utils/exec.js.map +1 -0
- package/dist/src/utils/get-version.d.ts +6 -0
- package/dist/src/utils/get-version.js +14 -0
- package/dist/src/utils/get-version.js.map +1 -0
- package/dist/src/utils/github.d.ts +4 -0
- package/dist/src/utils/github.js +17 -0
- package/dist/src/utils/github.js.map +1 -0
- package/dist/src/utils/helm.d.ts +16 -32
- package/dist/src/utils/helm.js +15 -83
- package/dist/src/utils/helm.js.map +1 -1
- package/dist/src/utils/import-esm.js.map +1 -0
- package/dist/src/utils/{common/tsh.d.ts → tsh.d.ts} +0 -1
- package/dist/src/utils/{common/tsh.js → tsh.js} +15 -20
- package/dist/src/utils/tsh.js.map +1 -0
- package/executors.json +2 -12
- package/package.json +18 -42
- package/dist/src/codegen.d.ts +0 -3
- package/dist/src/codegen.js +0 -25
- package/dist/src/codegen.js.map +0 -1
- package/dist/src/executors/preview-deploy/README.md +0 -5
- package/dist/src/executors/preview-deploy/argocdOverride.d.ts +0 -4
- package/dist/src/executors/preview-deploy/argocdOverride.js +0 -22
- package/dist/src/executors/preview-deploy/argocdOverride.js.map +0 -1
- package/dist/src/executors/preview-deploy/executor.d.ts +0 -4
- package/dist/src/executors/preview-deploy/executor.js +0 -143
- package/dist/src/executors/preview-deploy/executor.js.map +0 -1
- package/dist/src/executors/preview-deploy/kargoPolicy.d.ts +0 -14
- package/dist/src/executors/preview-deploy/kargoPolicy.js +0 -69
- package/dist/src/executors/preview-deploy/kargoPolicy.js.map +0 -1
- package/dist/src/executors/preview-deploy/schema.json +0 -28
- package/dist/src/executors/publisher/README.md +0 -3
- package/dist/src/executors/publisher/lambda.d.ts +0 -18
- package/dist/src/executors/publisher/lambda.js +0 -86
- package/dist/src/executors/publisher/lambda.js.map +0 -1
- package/dist/src/executors/release/README.md +0 -15
- package/dist/src/executors/release/executor.d.ts +0 -4
- package/dist/src/executors/release/executor.js +0 -104
- package/dist/src/executors/release/executor.js.map +0 -1
- package/dist/src/executors/release/schema.json +0 -37
- package/dist/src/generators/init/README.md +0 -5
- package/dist/src/generators/init/files/.circleci/config.yml.template +0 -232
- package/dist/src/generators/init/files/.circleci/teleport/shared-charts.conf.template +0 -24
- package/dist/src/generators/init/files/.npmrc.template +0 -1
- package/dist/src/generators/init/init.d.ts +0 -13
- package/dist/src/generators/init/init.js +0 -278
- package/dist/src/generators/init/init.js.map +0 -1
- package/dist/src/generators/init/schema.json +0 -7
- package/dist/src/scripts/codegen-with-auth.js +0 -55
- package/dist/src/scripts/version-actions.mock.d.ts +0 -6
- package/dist/src/scripts/version-actions.mock.js +0 -61
- package/dist/src/scripts/version-actions.mock.js.map +0 -1
- package/dist/src/utils/common/aws-auth.js +0 -145
- package/dist/src/utils/common/aws-auth.js.map +0 -1
- package/dist/src/utils/common/circleci.d.ts +0 -2
- package/dist/src/utils/common/circleci.js +0 -20
- package/dist/src/utils/common/circleci.js.map +0 -1
- package/dist/src/utils/common/exec.d.ts +0 -4
- package/dist/src/utils/common/exec.js +0 -52
- package/dist/src/utils/common/exec.js.map +0 -1
- package/dist/src/utils/common/github.d.ts +0 -20
- package/dist/src/utils/common/github.js +0 -60
- package/dist/src/utils/common/github.js.map +0 -1
- package/dist/src/utils/common/import-esm.js.map +0 -1
- package/dist/src/utils/common/logger.d.ts +0 -1
- package/dist/src/utils/common/logger.js +0 -8
- package/dist/src/utils/common/logger.js.map +0 -1
- package/dist/src/utils/common/nx.d.ts +0 -22
- package/dist/src/utils/common/nx.js +0 -174
- package/dist/src/utils/common/nx.js.map +0 -1
- package/dist/src/utils/common/s3.d.ts +0 -1
- package/dist/src/utils/common/s3.js +0 -18
- package/dist/src/utils/common/s3.js.map +0 -1
- package/dist/src/utils/common/tsh.js.map +0 -1
- package/dist/src/utils/datadog.d.ts +0 -1
- package/dist/src/utils/datadog.js +0 -33
- package/dist/src/utils/datadog.js.map +0 -1
- package/dist/src/utils/helm.mock.d.ts +0 -85
- package/dist/src/utils/helm.mock.js +0 -100
- package/dist/src/utils/helm.mock.js.map +0 -1
- package/dist/src/utils/lambda/aws-lambda.d.ts +0 -47
- package/dist/src/utils/lambda/aws-lambda.js +0 -231
- package/dist/src/utils/lambda/aws-lambda.js.map +0 -1
- package/dist/src/utils/lambda/lambda.d.ts +0 -7
- package/dist/src/utils/lambda/lambda.js +0 -20
- package/dist/src/utils/lambda/lambda.js.map +0 -1
- package/dist/src/utils/lambda/oci.d.ts +0 -8
- package/dist/src/utils/lambda/oci.js +0 -22
- package/dist/src/utils/lambda/oci.js.map +0 -1
- package/dist/src/utils/lambda/publish.d.ts +0 -14
- package/dist/src/utils/lambda/publish.js +0 -44
- package/dist/src/utils/lambda/publish.js.map +0 -1
- package/dist/src/utils/lambda/spacelift.d.ts +0 -3
- package/dist/src/utils/lambda/spacelift.js +0 -55
- package/dist/src/utils/lambda/spacelift.js.map +0 -1
- package/dist/src/utils/spacelift/lib/__generated__/fragment-masking.d.ts +0 -19
- package/dist/src/utils/spacelift/lib/__generated__/fragment-masking.js +0 -22
- package/dist/src/utils/spacelift/lib/__generated__/fragment-masking.js.map +0 -1
- package/dist/src/utils/spacelift/lib/__generated__/gql.d.ts +0 -15
- package/dist/src/utils/spacelift/lib/__generated__/gql.js +0 -8
- package/dist/src/utils/spacelift/lib/__generated__/gql.js.map +0 -1
- package/dist/src/utils/spacelift/lib/__generated__/graphql.d.ts +0 -9426
- package/dist/src/utils/spacelift/lib/__generated__/graphql.js +0 -819
- package/dist/src/utils/spacelift/lib/__generated__/graphql.js.map +0 -1
- package/dist/src/utils/spacelift/lib/__generated__/index.d.ts +0 -2
- package/dist/src/utils/spacelift/lib/__generated__/index.js +0 -6
- package/dist/src/utils/spacelift/lib/__generated__/index.js.map +0 -1
- package/dist/src/utils/spacelift/lib/graphql.service.d.ts +0 -18
- package/dist/src/utils/spacelift/lib/graphql.service.js +0 -186
- package/dist/src/utils/spacelift/lib/graphql.service.js.map +0 -1
- package/dist/src/utils/spacelift/lib/query/spacelift.queries.d.ts +0 -34
- package/dist/src/utils/spacelift/lib/query/spacelift.queries.js +0 -48
- package/dist/src/utils/spacelift/lib/query/spacelift.queries.js.map +0 -1
- package/dist/src/utils/spacelift/lib/spacelift.error.d.ts +0 -43
- package/dist/src/utils/spacelift/lib/spacelift.error.js +0 -63
- package/dist/src/utils/spacelift/lib/spacelift.error.js.map +0 -1
- package/dist/src/utils/spacelift/lib/spacelift.service.d.ts +0 -16
- package/dist/src/utils/spacelift/lib/spacelift.service.js +0 -58
- package/dist/src/utils/spacelift/lib/spacelift.service.js.map +0 -1
- package/dist/src/utils/spacelift/lib/utils.d.ts +0 -4
- package/dist/src/utils/spacelift/lib/utils.js +0 -32
- package/dist/src/utils/spacelift/lib/utils.js.map +0 -1
- package/generators.json +0 -9
- /package/dist/src/utils/{common/import-esm.d.ts → import-esm.d.ts} +0 -0
- /package/dist/src/utils/{common/import-esm.js → import-esm.js} +0 -0
package/dist/src/utils/helm.js
CHANGED
|
@@ -4,23 +4,20 @@ exports.getHelmChartFile = getHelmChartFile;
|
|
|
4
4
|
exports.setupTeleportProxyHelmChartFile = setupTeleportProxyHelmChartFile;
|
|
5
5
|
exports.resetTeleportProxyHelmChartFile = resetTeleportProxyHelmChartFile;
|
|
6
6
|
exports.installHelmRepo = installHelmRepo;
|
|
7
|
-
exports.patchImageTag = patchImageTag;
|
|
8
7
|
exports.packageHelm = packageHelm;
|
|
9
8
|
exports.pushPackagedHelm = pushPackagedHelm;
|
|
10
|
-
exports.pushOciPackagedHelm = pushOciPackagedHelm;
|
|
11
9
|
const fs = require("node:fs");
|
|
12
10
|
const process = require("node:process");
|
|
13
|
-
const
|
|
14
|
-
const aws_auth_1 = require("./
|
|
15
|
-
const exec_1 = require("./
|
|
16
|
-
const logger_1 = require("./common/logger");
|
|
11
|
+
const yaml_1 = require("yaml");
|
|
12
|
+
const aws_auth_1 = require("./aws-auth");
|
|
13
|
+
const exec_1 = require("./exec");
|
|
17
14
|
const tshProxy = 'http://localhost';
|
|
18
15
|
/**
|
|
19
16
|
* Read & parse the Helm chart.yaml file
|
|
20
17
|
* @param helmFolderPath
|
|
21
18
|
*/
|
|
22
19
|
async function getHelmChartFile(helmFolderPath) {
|
|
23
|
-
return
|
|
20
|
+
return (0, yaml_1.parse)(fs.readFileSync(`${helmFolderPath}/Chart.yaml`, 'utf8'));
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Prepare the Chart.yaml config file for the Tsh proxy
|
|
@@ -28,8 +25,8 @@ async function getHelmChartFile(helmFolderPath) {
|
|
|
28
25
|
* @param tshPort
|
|
29
26
|
*/
|
|
30
27
|
async function setupTeleportProxyHelmChartFile(helmFolderPath, tshPort) {
|
|
31
|
-
|
|
32
|
-
let chartConfigStr =
|
|
28
|
+
console.log(`Replacing charts.shared.payfit.tech -> localhost:${tshPort} for the Teleport proxy`);
|
|
29
|
+
let chartConfigStr = (0, yaml_1.stringify)(await getHelmChartFile(helmFolderPath));
|
|
33
30
|
chartConfigStr = chartConfigStr.replace(/(https?:\/\/)charts(\.shared)?\.payfit\.tech/gi, `${tshProxy}:${tshPort}`);
|
|
34
31
|
return fs.writeFileSync(`${helmFolderPath}/Chart.yaml`, chartConfigStr);
|
|
35
32
|
}
|
|
@@ -39,7 +36,7 @@ async function setupTeleportProxyHelmChartFile(helmFolderPath, tshPort) {
|
|
|
39
36
|
* @param tshPort
|
|
40
37
|
*/
|
|
41
38
|
async function resetTeleportProxyHelmChartFile(helmFolderPath, tshPort) {
|
|
42
|
-
let chartConfigStr =
|
|
39
|
+
let chartConfigStr = (0, yaml_1.stringify)(await getHelmChartFile(helmFolderPath));
|
|
43
40
|
chartConfigStr = chartConfigStr.replace(`${tshProxy}:${tshPort}`, 'https://charts.shared.payfit.tech');
|
|
44
41
|
return fs.writeFileSync(`${helmFolderPath}/Chart.yaml`, chartConfigStr);
|
|
45
42
|
}
|
|
@@ -59,66 +56,15 @@ async function installHelmRepo(helmFolderPath) {
|
|
|
59
56
|
if (!process.env.CHARTMUSEUM_USERNAME ||
|
|
60
57
|
!process.env.CHARTMUSEUM_PASSWORD)
|
|
61
58
|
throw new Error('Missing CHARTMUSEUM_USERNAME, CHARTMUSEUM_PASSWORD in environment!');
|
|
62
|
-
await (0, exec_1.
|
|
59
|
+
await (0, exec_1.exec_command)(`helm repo add --username '${process.env.CHARTMUSEUM_USERNAME}' --password '${process.env.CHARTMUSEUM_PASSWORD}' '${repoName}' '${dep.repository}' --force-update`);
|
|
63
60
|
}
|
|
64
61
|
else {
|
|
65
|
-
await (0, exec_1.
|
|
62
|
+
await (0, exec_1.exec_command)(`helm repo add '${repoName}' '${dep.repository}' --force-update`);
|
|
66
63
|
}
|
|
67
|
-
await (0, exec_1.
|
|
64
|
+
await (0, exec_1.exec_command)(`helm repo update ${repoName}`);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
return (0, exec_1.
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Patch Docker image tag in values.yaml
|
|
74
|
-
* @param valuesConfigPath
|
|
75
|
-
* @param chartConfigPath
|
|
76
|
-
* @param version
|
|
77
|
-
*/
|
|
78
|
-
async function patchImageTag(valuesConfigPath, chartConfigPath, version) {
|
|
79
|
-
if (fs.existsSync(valuesConfigPath)) {
|
|
80
|
-
logger_1.consola.log('Values files detected, trying to patch Docker image tag');
|
|
81
|
-
const values = YAML.parse(fs.readFileSync(valuesConfigPath, 'utf8'));
|
|
82
|
-
const chart = YAML.parse(fs.readFileSync(chartConfigPath, 'utf8'));
|
|
83
|
-
let shouldUpdateFile = false;
|
|
84
|
-
// Patch the global image tag
|
|
85
|
-
if (values.image?.tag) {
|
|
86
|
-
values.image.tag = version;
|
|
87
|
-
logger_1.consola.log(`Patched Docker global image tag`);
|
|
88
|
-
shouldUpdateFile = true;
|
|
89
|
-
}
|
|
90
|
-
// Patch the image tag for the deps service
|
|
91
|
-
if (chart.dependencies) {
|
|
92
|
-
for (const dep of chart.dependencies) {
|
|
93
|
-
if (values[dep.alias]) {
|
|
94
|
-
if (values[dep.alias]?.image?.tag) {
|
|
95
|
-
values[dep.alias].image.tag = version;
|
|
96
|
-
shouldUpdateFile = true;
|
|
97
|
-
logger_1.consola.log(`Patched Docker image tag for the service ${dep.alias} successfully`);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
logger_1.consola.warn(`Failed to find image.tag key for the service ${dep.alias}`);
|
|
101
|
-
}
|
|
102
|
-
if (values[dep.alias]?.dbMigration?.image?.tag) {
|
|
103
|
-
values[dep.alias].dbMigration.image.tag = version;
|
|
104
|
-
shouldUpdateFile = true;
|
|
105
|
-
logger_1.consola.log(`Patched Docker image tag for the dbMigration of the service ${dep.alias} successfully`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
logger_1.consola.warn(`Failed to find the service key ${dep.alias} in the values.yaml file`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (shouldUpdateFile) {
|
|
114
|
-
fs.writeFileSync(valuesConfigPath, YAML.stringify(values), {
|
|
115
|
-
encoding: 'utf8',
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
logger_1.consola.warn(`No values.yaml file detected at ${valuesConfigPath}, can't patch Docker image tag`);
|
|
121
|
-
}
|
|
67
|
+
return (0, exec_1.exec_command)(`helm dependency update ${helmFolderPath}`);
|
|
122
68
|
}
|
|
123
69
|
/**
|
|
124
70
|
* Package the Helm chart
|
|
@@ -127,33 +73,19 @@ async function patchImageTag(valuesConfigPath, chartConfigPath, version) {
|
|
|
127
73
|
* @param destinationPath
|
|
128
74
|
*/
|
|
129
75
|
async function packageHelm(helmFolderPath, version, destinationPath) {
|
|
130
|
-
return (0, exec_1.
|
|
76
|
+
return (0, exec_1.exec_command)(`helm package ${helmFolderPath} --version ${version} --app-version ${version} --destination ${destinationPath}`);
|
|
131
77
|
}
|
|
132
78
|
/**
|
|
133
79
|
* Push the packaged Helm chart in the chartmuseum
|
|
134
80
|
* @param packagedHelmChartFilePath
|
|
135
|
-
* @param packagedHelmChartName
|
|
136
81
|
* @param projectName
|
|
137
82
|
* @param branch
|
|
138
83
|
*/
|
|
139
|
-
async function pushPackagedHelm(packagedHelmChartFilePath,
|
|
84
|
+
async function pushPackagedHelm(packagedHelmChartFilePath, projectName, branch) {
|
|
140
85
|
if (!process.env.CHARTMUSEUM_BUCKET_NAME)
|
|
141
86
|
throw new Error('Missing CHARTMUSEUM_BUCKET_NAME in environment!');
|
|
87
|
+
// aws s3api put-object-tagging --bucket ${process.env.CHARTMUSEUM_BUCKET_NAME} --key ${projectName}/${branch}/${packagedHelmChartFilePath} --tagging '{"TagSet": [{ "Key": "auto-purge", "Value": "false" }]}' // todo
|
|
142
88
|
const profile = (0, aws_auth_1.getProfileName)() === 'default' ? '' : `--profile ${(0, aws_auth_1.getProfileName)()}`;
|
|
143
|
-
|
|
144
|
-
if (packagedHelmChartFilePath.includes('ephemeral')) {
|
|
145
|
-
await (0, exec_1.exec)(`aws s3api put-object-tagging ${profile} --bucket ${process.env.CHARTMUSEUM_BUCKET_NAME} --key ${projectName}/${branch}/${packagedHelmChartName} --tagging '{"TagSet": [{ "Key": "auto-purge", "Value": "true" }]}'`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Push the packaged Helm chart to an OCI-compatible ECR repository
|
|
150
|
-
* @param packagedHelmChartFilePath
|
|
151
|
-
* @param ecrRegistry
|
|
152
|
-
*/
|
|
153
|
-
async function pushOciPackagedHelm(packagedHelmChartFilePath, ecrRegistry) {
|
|
154
|
-
// Login to ECR
|
|
155
|
-
await (0, aws_auth_1.loginToEcr)(process.env.AWS_ECR_REGISTRY);
|
|
156
|
-
// Push the Helm chart to ECR using OCI format
|
|
157
|
-
return (0, exec_1.exec)(`helm push ${packagedHelmChartFilePath} oci://${ecrRegistry}`);
|
|
89
|
+
return (0, exec_1.exec_command)(`aws s3 cp ${profile} --sse AES256 ${packagedHelmChartFilePath} s3://${process.env.CHARTMUSEUM_BUCKET_NAME}/${projectName}/${branch}/`);
|
|
158
90
|
}
|
|
159
91
|
//# sourceMappingURL=helm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../../src/utils/helm.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../../src/utils/helm.ts"],"names":[],"mappings":";;AAcA,4CAEC;AAOD,0EAaC;AAOD,0EAUC;AAMD,0CA4BC;AAQD,kCAQC;AAQD,4CAaC;AA5HD,8BAA6B;AAC7B,wCAAuC;AAEvC,+BAAu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AI,KAAK,CAAC,iDAAiD,CAAC,CAAA;IACpE,uNAAuN;IACvN,MAAM,OAAO,GACX,IAAA,yBAAc,GAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAA,yBAAc,GAAE,EAAE,CAAA;IACvE,OAAO,IAAA,mBAAY,EACjB,aAAa,OAAO,iBAAiB,yBAAyB,SAAS,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,WAAW,IAAI,MAAM,GAAG,CACvI,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-esm.js","sourceRoot":"","sources":["../../../src/utils/import-esm.ts"],"names":[],"mappings":";;AACA,4BAEC;AAED,sCAIC;AATD,+GAA+G;AAC/G,SAAgB,QAAQ;IACtB,OAAO,QAAQ,CAAC,qBAAqB,CAAC,EAAkC,CAAA;AAC1E,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,QAAQ,CAAC,2BAA2B,CAAC,EAE3C,CAAA;AACH,CAAC"}
|
|
@@ -5,12 +5,10 @@ exports.isLoggedInToTsh = isLoggedInToTsh;
|
|
|
5
5
|
exports.ensureIsLoggedInToTsh = ensureIsLoggedInToTsh;
|
|
6
6
|
exports.isConnectedToChartMuseum = isConnectedToChartMuseum;
|
|
7
7
|
exports.ensureAppIsChartMuseum = ensureAppIsChartMuseum;
|
|
8
|
-
exports.startTbot = startTbot;
|
|
9
8
|
const workspace_root_1 = require("nx/src/utils/workspace-root");
|
|
10
9
|
const zod_1 = require("zod");
|
|
11
10
|
const exec_1 = require("./exec");
|
|
12
11
|
const import_esm_1 = require("./import-esm");
|
|
13
|
-
const logger_1 = require("./logger");
|
|
14
12
|
const expectedProfileUrl = 'https://payfit.teleport.sh:443';
|
|
15
13
|
const expectedAppName = 'charts-shared';
|
|
16
14
|
const profile = zod_1.z.object({
|
|
@@ -21,7 +19,7 @@ const statusSchema = zod_1.z.object({
|
|
|
21
19
|
profiles: zod_1.z.array(profile).optional(),
|
|
22
20
|
});
|
|
23
21
|
const getStatusOfTsh = async () => {
|
|
24
|
-
const { stdout } = await (0, exec_1.
|
|
22
|
+
const { stdout } = await (0, exec_1.execTiny)('tsh', `status -f json`.split(' '));
|
|
25
23
|
return statusSchema.parse(JSON.parse(stdout));
|
|
26
24
|
};
|
|
27
25
|
async function isLoggedInToTsh() {
|
|
@@ -37,11 +35,15 @@ async function ensureIsLoggedInToTsh() {
|
|
|
37
35
|
if (await isLoggedInToTsh()) {
|
|
38
36
|
return true;
|
|
39
37
|
}
|
|
40
|
-
await (0, exec_1.
|
|
38
|
+
await (0, exec_1.execTiny)('tsh', `login --proxy=${expectedProfileUrl} --auth=okta`.split(' '), {
|
|
39
|
+
throwOnError: true,
|
|
40
|
+
});
|
|
41
41
|
return await isLoggedInToTsh();
|
|
42
42
|
}
|
|
43
43
|
const getAppConfigOfTsh = async () => {
|
|
44
|
-
const { stdout } = await (0, exec_1.
|
|
44
|
+
const { stdout } = await (0, exec_1.execTiny)('tsh', `apps config -f json --proxy=${expectedProfileUrl} ${expectedAppName}`.split(' '), {
|
|
45
|
+
throwOnError: true,
|
|
46
|
+
});
|
|
45
47
|
return JSON.parse(stdout);
|
|
46
48
|
};
|
|
47
49
|
async function isConnectedToChartMuseum() {
|
|
@@ -57,7 +59,9 @@ async function ensureAppIsChartMuseum() {
|
|
|
57
59
|
if (await isConnectedToChartMuseum()) {
|
|
58
60
|
return true;
|
|
59
61
|
}
|
|
60
|
-
await (0, exec_1.
|
|
62
|
+
await (0, exec_1.execTiny)('tsh', `apps login ${expectedAppName} --proxy=${expectedProfileUrl}`.split(' '), {
|
|
63
|
+
throwOnError: true,
|
|
64
|
+
});
|
|
61
65
|
return await isConnectedToChartMuseum();
|
|
62
66
|
}
|
|
63
67
|
const getLocalPortForChartMuseum = async () => {
|
|
@@ -69,17 +73,16 @@ const getLocalPortForChartMuseum = async () => {
|
|
|
69
73
|
const { default: ky } = await (0, import_esm_1.importKy)();
|
|
70
74
|
const port = await getPort();
|
|
71
75
|
const command = process.env.CI
|
|
72
|
-
?
|
|
73
|
-
: `
|
|
74
|
-
const execHandle = (0, exec_1.
|
|
75
|
-
throwOnError: true,
|
|
76
|
+
? `-i ./certs/identity --proxy payfit.teleport.sh:443 proxy app ${expectedAppName} --port ${port}`
|
|
77
|
+
: `proxy app ${expectedAppName} -p ${port}`;
|
|
78
|
+
const execHandle = (0, exec_1.execTiny)('tsh', command.split(' '), {
|
|
76
79
|
nodeOptions: {
|
|
77
80
|
cwd: workspace_root_1.workspaceRoot,
|
|
78
81
|
},
|
|
79
82
|
});
|
|
80
83
|
const isReady = async () => {
|
|
81
84
|
for await (const line of execHandle) {
|
|
82
|
-
|
|
85
|
+
console.log(`[TSH] ${line}`);
|
|
83
86
|
if (line.includes('Proxying connections')) {
|
|
84
87
|
return true;
|
|
85
88
|
}
|
|
@@ -92,7 +95,7 @@ const getLocalPortForChartMuseum = async () => {
|
|
|
92
95
|
});
|
|
93
96
|
return {
|
|
94
97
|
[Symbol.dispose]: async () => {
|
|
95
|
-
|
|
98
|
+
console.log(`Terminating tsh proxy on port ${port}`);
|
|
96
99
|
execHandle.kill();
|
|
97
100
|
},
|
|
98
101
|
fetchClient,
|
|
@@ -101,12 +104,4 @@ const getLocalPortForChartMuseum = async () => {
|
|
|
101
104
|
};
|
|
102
105
|
};
|
|
103
106
|
exports.getLocalPortForChartMuseum = getLocalPortForChartMuseum;
|
|
104
|
-
async function startTbot() {
|
|
105
|
-
return (0, exec_1.exec)(`tbot start -c ${workspace_root_1.workspaceRoot}/.circleci/teleport/shared-charts.conf`, {
|
|
106
|
-
throwOnError: true,
|
|
107
|
-
nodeOptions: {
|
|
108
|
-
stdio: 'inherit',
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
107
|
//# sourceMappingURL=tsh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsh.js","sourceRoot":"","sources":["../../../src/utils/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/publisher/executor",
|
|
5
|
+
"schema": "./src/executors/publisher/schema.json",
|
|
6
6
|
"description": "Docker & Helm publisher executor"
|
|
7
|
-
},
|
|
8
|
-
"release": {
|
|
9
|
-
"implementation": "./dist/src/executors/release/executor",
|
|
10
|
-
"schema": "./dist/src/executors/release/schema.json",
|
|
11
|
-
"description": "Custom release executor"
|
|
12
|
-
},
|
|
13
|
-
"preview-deploy": {
|
|
14
|
-
"implementation": "./dist/src/executors/preview-deploy/executor",
|
|
15
|
-
"schema": "./dist/src/executors/preview-deploy/schema.json",
|
|
16
|
-
"description": "Custom preview-deploy executor"
|
|
17
7
|
}
|
|
18
8
|
}
|
|
19
9
|
}
|
package/package.json
CHANGED
|
@@ -1,60 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/nx-core",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-semver",
|
|
4
4
|
"type": "commonjs",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
7
|
-
"typings": "
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"typings": "dist/src/index.d.ts",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "
|
|
10
|
+
"url": "https://github.com/payfit/nx-common-packages.git",
|
|
11
11
|
"directory": "packages/nx-core"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"@graphql-typed-document-node/core": "^3.2.0",
|
|
16
|
-
"@nx/devkit": "21.3.11",
|
|
17
|
-
"@nx/js": "21.3.11",
|
|
18
|
-
"@octokit/auth-app": "^8.0.2",
|
|
19
|
-
"@octokit/rest": "^22.0.0",
|
|
20
|
-
"args-tokenizer": "^0.3.0",
|
|
21
|
-
"consola": "^3.4.2",
|
|
22
|
-
"cross-fetch": "4.1.0",
|
|
14
|
+
"@nx/devkit": "21.0.3",
|
|
23
15
|
"get-port": "^7.1.0",
|
|
24
|
-
"graphql": "^16.6.0",
|
|
25
16
|
"ky": "^1.8.1",
|
|
17
|
+
"nx": "21.0.3",
|
|
26
18
|
"semver": "7.7.2",
|
|
27
|
-
"tinyexec": "
|
|
19
|
+
"tinyexec": "0.3.2",
|
|
28
20
|
"tslib": "^2.8.1",
|
|
29
|
-
"yaml": "2.
|
|
30
|
-
"zod": "^
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"nx": "^21"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@graphql-codegen/cli": "^5.0.7",
|
|
37
|
-
"nx": "21.3.11"
|
|
38
|
-
},
|
|
39
|
-
"exports": {
|
|
40
|
-
".": {
|
|
41
|
-
"types": "./dist/src/index.d.ts",
|
|
42
|
-
"require": "./dist/src/index.js",
|
|
43
|
-
"default": "./dist/src/index.js"
|
|
44
|
-
},
|
|
45
|
-
"./versionActions": "./dist/src/scripts/version-actions.js",
|
|
46
|
-
"./package.json": "./package.json"
|
|
21
|
+
"yaml": "^2.7.0",
|
|
22
|
+
"zod": "^3.24.3"
|
|
47
23
|
},
|
|
48
24
|
"executors": "./executors.json",
|
|
49
|
-
"generators": "./generators.json",
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"access": "restricted"
|
|
52
|
-
},
|
|
53
25
|
"files": [
|
|
54
26
|
"dist",
|
|
55
|
-
"
|
|
56
|
-
"executors.json",
|
|
27
|
+
"!**/*.tsbuildinfo",
|
|
57
28
|
"generators.json",
|
|
58
|
-
"
|
|
59
|
-
]
|
|
29
|
+
"executors.json"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./dist/src/index.js",
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
"./versionActions": "./dist/src/scripts/version-actions.js"
|
|
35
|
+
}
|
|
60
36
|
}
|
package/dist/src/codegen.d.ts
DELETED
package/dist/src/codegen.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path = './packages/nx-core/src/utils/spacelift/lib/__generated__/';
|
|
4
|
-
const config = {
|
|
5
|
-
schema: {
|
|
6
|
-
[process.env.SPACELIFT_API_URL ||
|
|
7
|
-
'https://payfit.app.spacelift.io/graphql']: {
|
|
8
|
-
headers: {
|
|
9
|
-
Authorization: `Bearer ${process.env.SPACELIFT_JWT_TOKEN}`,
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
generates: {
|
|
14
|
-
[path]: {
|
|
15
|
-
preset: 'client',
|
|
16
|
-
plugins: [],
|
|
17
|
-
presetConfig: {
|
|
18
|
-
gqlTagName: 'gql',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
ignoreNoDocuments: true,
|
|
23
|
-
};
|
|
24
|
-
exports.default = config;
|
|
25
|
-
//# sourceMappingURL=codegen.js.map
|
package/dist/src/codegen.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/codegen.ts"],"names":[],"mappings":";;AAEA,MAAM,IAAI,GAAG,2DAA2D,CAAA;AAExE,MAAM,MAAM,GAAkB;IAC5B,MAAM,EAAE;QACN,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB;YAC9B,yCAAyC,CAAC,EAAE;YAC1C,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;aAC3D;SACF;KACF;IACD,SAAS,EAAE;QACT,CAAC,IAAI,CAAC,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,EAAE;YACX,YAAY,EAAE;gBACZ,UAAU,EAAE,KAAK;aAClB;SACF;KACF;IACD,iBAAiB,EAAE,IAAI;CACxB,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# nx-core preview-deploy executor
|
|
2
|
-
|
|
3
|
-
This executor updates the ArgoCD and Kargo policy configurations to switch the deployment of a specific application to a different branch for a given environment.
|
|
4
|
-
|
|
5
|
-
It is based on the [domain-enrollment documentation](https://github.com/PayFit/domain-enrollment/blob/main/docs/how-to/002-sync-dev-pr.md)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateArgoCDOverride = updateArgoCDOverride;
|
|
4
|
-
const github_1 = require("../../utils/common/github");
|
|
5
|
-
/**
|
|
6
|
-
* Updates the ArgoCD override configuration based on the target branch
|
|
7
|
-
*/
|
|
8
|
-
function updateArgoCDOverride(argocdOverride, targetBranchName) {
|
|
9
|
-
// Handle main/master branches - remove target revision
|
|
10
|
-
if ((0, github_1.isDefaultBranch)(targetBranchName)) {
|
|
11
|
-
if (argocdOverride.targetRevision) {
|
|
12
|
-
delete argocdOverride.targetRevision;
|
|
13
|
-
return argocdOverride;
|
|
14
|
-
}
|
|
15
|
-
// No changes needed if targetRevision doesn't exist
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
// Handle feature branches - set target revision
|
|
19
|
-
argocdOverride.targetRevision = targetBranchName;
|
|
20
|
-
return argocdOverride;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=argocdOverride.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"argocdOverride.js","sourceRoot":"","sources":["../../../../src/executors/preview-deploy/argocdOverride.ts"],"names":[],"mappings":";;AAKA,oDAiBC;AAtBD,sDAA2D;AAE3D;;GAEG;AACH,SAAgB,oBAAoB,CAClC,cAAuC,EACvC,gBAAwB;IAExB,uDAAuD;IACvD,IAAI,IAAA,wBAAe,EAAC,gBAAgB,CAAC,EAAE,CAAC;QACtC,IAAI,cAAc,CAAC,cAAc,EAAE,CAAC;YAClC,OAAO,cAAc,CAAC,cAAc,CAAA;YACpC,OAAO,cAAc,CAAA;QACvB,CAAC;QACD,oDAAoD;QACpD,OAAM;IACR,CAAC;IAED,gDAAgD;IAChD,cAAc,CAAC,cAAc,GAAG,gBAAgB,CAAA;IAChD,OAAO,cAAc,CAAA;AACvB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { PreviewDeployExecutorOptions, PreviewDeployExecutorSchema } from './schema';
|
|
3
|
-
declare const runExecutor: (options: PreviewDeployExecutorOptions, context: ExecutorContext) => Promise<PreviewDeployExecutorSchema>;
|
|
4
|
-
export default runExecutor;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const auth_app_1 = require("@octokit/auth-app");
|
|
4
|
-
const rest_1 = require("@octokit/rest");
|
|
5
|
-
const yaml = require("yaml");
|
|
6
|
-
const logger_1 = require("../../utils/common/logger");
|
|
7
|
-
const argocdOverride_1 = require("./argocdOverride");
|
|
8
|
-
const kargoPolicy_1 = require("./kargoPolicy");
|
|
9
|
-
function readFileYamlContent(file) {
|
|
10
|
-
if (!file) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
// Verify both are files (not directories)
|
|
14
|
-
if (Array.isArray(file.data)) {
|
|
15
|
-
throw new Error('Expected files, but found directories');
|
|
16
|
-
}
|
|
17
|
-
// Type guard to ensure we have file content
|
|
18
|
-
if (file.data.type !== 'file') {
|
|
19
|
-
throw new Error('Expected file type, got symlink or submodule');
|
|
20
|
-
}
|
|
21
|
-
// Decode base64 content and parse YAML
|
|
22
|
-
const fileContent = Buffer.from(file.data.content, 'base64').toString('utf-8');
|
|
23
|
-
try {
|
|
24
|
-
return yaml.parse(fileContent);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
throw new Error(`Failed to parse YAML file: ${error}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function getEnvVar(name) {
|
|
31
|
-
const value = process.env[name];
|
|
32
|
-
if (!value) {
|
|
33
|
-
throw new Error(`Missing env var ${name}`);
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
const runExecutor = async (options) => {
|
|
38
|
-
logger_1.consola.box(`Start preview deploy switch for ${options.targetAppName} to target branch ${options.targetBranchName} on the ${options.targetEnv} env`);
|
|
39
|
-
const octokit = process.env.GITHUB_TOKEN
|
|
40
|
-
? new rest_1.Octokit({ auth: process.env.GITHUB_TOKEN })
|
|
41
|
-
: new rest_1.Octokit({
|
|
42
|
-
authStrategy: auth_app_1.createAppAuth,
|
|
43
|
-
auth: {
|
|
44
|
-
appId: getEnvVar('GITHUB_APP_ID'),
|
|
45
|
-
privateKey: getEnvVar('GITHUB_PRIVATE_KEY'),
|
|
46
|
-
installationId: getEnvVar('GITHUB_INSTALLATION_ID'),
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
const argocdOverridePath = `apps/${options.targetAppName}/${options.targetEnv}/.argocd-override.yaml`;
|
|
50
|
-
const kargoPolicyPath = `.kargo/policy.yaml`;
|
|
51
|
-
const message = `chore(${options.targetAppName}): switch deployment branch to ${options.targetBranchName} on ${options.targetEnv}`;
|
|
52
|
-
// Retrieve both files - throw error if either doesn't exist
|
|
53
|
-
const [argocdOverrideFile, kargoPolicyFile] = await Promise.all([
|
|
54
|
-
octokit.repos
|
|
55
|
-
.getContent({
|
|
56
|
-
owner: 'PayFit',
|
|
57
|
-
repo: options.targetRepo,
|
|
58
|
-
path: argocdOverridePath,
|
|
59
|
-
ref: 'heads/main',
|
|
60
|
-
})
|
|
61
|
-
.catch(e => {
|
|
62
|
-
// we don't update this file if it does not exist as it's optional
|
|
63
|
-
if (e.status === 404) {
|
|
64
|
-
logger_1.consola.info(`${options.targetRepo}/${argocdOverridePath} not found, ignoring this file`);
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
throw e;
|
|
68
|
-
}),
|
|
69
|
-
octokit.repos
|
|
70
|
-
.getContent({
|
|
71
|
-
owner: 'PayFit',
|
|
72
|
-
repo: options.targetRepo,
|
|
73
|
-
path: kargoPolicyPath,
|
|
74
|
-
ref: 'heads/main',
|
|
75
|
-
})
|
|
76
|
-
.catch(e => {
|
|
77
|
-
if (e.status === 404) {
|
|
78
|
-
throw new Error(`${options.targetRepo}/${kargoPolicyPath} not found`);
|
|
79
|
-
}
|
|
80
|
-
throw e;
|
|
81
|
-
}),
|
|
82
|
-
]);
|
|
83
|
-
let argocdOverrideYaml = readFileYamlContent(argocdOverrideFile);
|
|
84
|
-
let kargoPolicyYaml = readFileYamlContent(kargoPolicyFile);
|
|
85
|
-
if (argocdOverrideYaml)
|
|
86
|
-
argocdOverrideYaml = (0, argocdOverride_1.updateArgoCDOverride)(argocdOverrideYaml, options.targetBranchName);
|
|
87
|
-
kargoPolicyYaml = (0, kargoPolicy_1.updateKargoPolicy)(kargoPolicyYaml, options.targetBranchName, options.targetEnv, options.targetAppName);
|
|
88
|
-
if (!argocdOverrideYaml && !kargoPolicyYaml) {
|
|
89
|
-
logger_1.consola.warn('Everything is already setup correctly, skipping');
|
|
90
|
-
return {
|
|
91
|
-
success: true,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
// Convert back to YAML and base64
|
|
95
|
-
if (argocdOverrideYaml) {
|
|
96
|
-
const updatedArgocdYaml = yaml.stringify(argocdOverrideYaml);
|
|
97
|
-
const updatedArgocdContent = Buffer.from(updatedArgocdYaml).toString('base64');
|
|
98
|
-
await octokit.repos.createOrUpdateFileContents({
|
|
99
|
-
owner: 'PayFit',
|
|
100
|
-
repo: options.targetRepo,
|
|
101
|
-
path: argocdOverridePath,
|
|
102
|
-
message,
|
|
103
|
-
content: updatedArgocdContent,
|
|
104
|
-
branch: 'main',
|
|
105
|
-
sha: argocdOverrideFile.data.sha,
|
|
106
|
-
committer: {
|
|
107
|
-
name: 'github-actions[bot]',
|
|
108
|
-
email: 'github-actions[bot]@users.noreply.github.com',
|
|
109
|
-
},
|
|
110
|
-
author: {
|
|
111
|
-
name: 'github-actions[bot]',
|
|
112
|
-
email: 'github-actions[bot]@users.noreply.github.com',
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
if (kargoPolicyYaml) {
|
|
117
|
-
const updatedKargoYaml = yaml.stringify(kargoPolicyYaml);
|
|
118
|
-
const updatedKargoContent = Buffer.from(updatedKargoYaml).toString('base64');
|
|
119
|
-
await octokit.repos.createOrUpdateFileContents({
|
|
120
|
-
owner: 'PayFit',
|
|
121
|
-
repo: options.targetRepo,
|
|
122
|
-
path: kargoPolicyPath,
|
|
123
|
-
message,
|
|
124
|
-
content: updatedKargoContent,
|
|
125
|
-
branch: 'main',
|
|
126
|
-
sha: kargoPolicyFile.data.sha,
|
|
127
|
-
committer: {
|
|
128
|
-
name: 'github-actions[bot]',
|
|
129
|
-
email: 'github-actions[bot]@users.noreply.github.com',
|
|
130
|
-
},
|
|
131
|
-
author: {
|
|
132
|
-
name: 'github-actions[bot]',
|
|
133
|
-
email: 'github-actions[bot]@users.noreply.github.com',
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
logger_1.consola.success('Preview deploy switch succeed !');
|
|
138
|
-
return {
|
|
139
|
-
success: true,
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
exports.default = runExecutor;
|
|
143
|
-
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../src/executors/preview-deploy/executor.ts"],"names":[],"mappings":";;AACA,gDAAiD;AACjD,wCAAuC;AACvC,6BAA4B;AAE5B,sDAAmD;AACnD,qDAAuD;AACvD,+CAA8D;AAM9D,SAAS,mBAAmB,CAAC,IAAS;IACpC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,0CAA0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YACD,MAAM,EAAE;gBACN,IAAI,EAAE,qBAAqB;gBAC3B,KAAK,EAAE,8CAA8C;aACtD;SACF,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAA;QACxD,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC5E,MAAM,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC;YAC7C,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,OAAO,CAAC,UAAU;YACxB,IAAI,EAAE,eAAe;YACrB,OAAO;YACP,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,MAAM;YACd,GAAG,EAAG,eAAe,CAAC,IAAY,CAAC,GAAG;YACtC,SAAS,EAAE;gBACT,IAAI,EAAE,qBAAqB;gBAC3B,KAAK,EAAE,8CAA8C;aACtD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,qBAAqB;gBAC3B,KAAK,EAAE,8CAA8C;aACtD;SACF,CAAC,CAAA;IACJ,CAAC;IAED,gBAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAA;IAElD,OAAO;QACL,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface KargoPolicy {
|
|
2
|
-
services?: Record<string, {
|
|
3
|
-
stages?: Record<string, {
|
|
4
|
-
ephemeralBranch?: string;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}>;
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
}>;
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Updates the Kargo policy configuration based on the target branch
|
|
13
|
-
*/
|
|
14
|
-
export declare function updateKargoPolicy(kargoPolicy: KargoPolicy, targetBranchName: string, targetEnv: string, targetAppName: string): KargoPolicy | undefined;
|