@payfit/nx-core 0.0.0-e2e
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 +173 -0
- package/dist/src/codegen.d.ts +3 -0
- package/dist/src/codegen.js +25 -0
- package/dist/src/codegen.js.map +1 -0
- package/dist/src/executors/preview-deploy/README.md +5 -0
- package/dist/src/executors/preview-deploy/argocdOverride.d.ts +4 -0
- package/dist/src/executors/preview-deploy/argocdOverride.js +22 -0
- package/dist/src/executors/preview-deploy/argocdOverride.js.map +1 -0
- package/dist/src/executors/preview-deploy/executor.d.ts +4 -0
- package/dist/src/executors/preview-deploy/executor.js +143 -0
- package/dist/src/executors/preview-deploy/executor.js.map +1 -0
- package/dist/src/executors/preview-deploy/kargoPolicy.d.ts +14 -0
- package/dist/src/executors/preview-deploy/kargoPolicy.js +69 -0
- package/dist/src/executors/preview-deploy/kargoPolicy.js.map +1 -0
- package/dist/src/executors/preview-deploy/schema.json +28 -0
- package/dist/src/executors/publisher/README.md +3 -0
- package/dist/src/executors/publisher/docker.d.ts +3 -0
- package/dist/src/executors/publisher/docker.js +66 -0
- package/dist/src/executors/publisher/docker.js.map +1 -0
- package/dist/src/executors/publisher/executor.d.ts +4 -0
- package/dist/src/executors/publisher/executor.js +20 -0
- package/dist/src/executors/publisher/executor.js.map +1 -0
- package/dist/src/executors/publisher/helm.d.ts +3 -0
- package/dist/src/executors/publisher/helm.js +69 -0
- package/dist/src/executors/publisher/helm.js.map +1 -0
- package/dist/src/executors/publisher/lambda.d.ts +18 -0
- package/dist/src/executors/publisher/lambda.js +86 -0
- package/dist/src/executors/publisher/lambda.js.map +1 -0
- package/dist/src/executors/publisher/schema.json +62 -0
- package/dist/src/executors/release/README.md +15 -0
- package/dist/src/executors/release/executor.d.ts +4 -0
- package/dist/src/executors/release/executor.js +104 -0
- package/dist/src/executors/release/executor.js.map +1 -0
- package/dist/src/executors/release/schema.json +37 -0
- package/dist/src/generators/init/README.md +5 -0
- package/dist/src/generators/init/files/.circleci/config.yml.template +232 -0
- package/dist/src/generators/init/files/.circleci/teleport/shared-charts.conf.template +24 -0
- package/dist/src/generators/init/files/.npmrc.template +1 -0
- package/dist/src/generators/init/init.d.ts +13 -0
- package/dist/src/generators/init/init.js +278 -0
- package/dist/src/generators/init/init.js.map +1 -0
- package/dist/src/generators/init/schema.json +7 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.js +118 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scripts/codegen-with-auth.js +55 -0
- package/dist/src/scripts/version-actions.d.ts +8 -0
- package/dist/src/scripts/version-actions.js +41 -0
- package/dist/src/scripts/version-actions.js.map +1 -0
- package/dist/src/scripts/version-actions.mock.d.ts +6 -0
- package/dist/src/scripts/version-actions.mock.js +61 -0
- package/dist/src/scripts/version-actions.mock.js.map +1 -0
- package/dist/src/utils/common/aws-auth.d.ts +47 -0
- package/dist/src/utils/common/aws-auth.js +145 -0
- package/dist/src/utils/common/aws-auth.js.map +1 -0
- package/dist/src/utils/common/circleci.d.ts +2 -0
- package/dist/src/utils/common/circleci.js +20 -0
- package/dist/src/utils/common/circleci.js.map +1 -0
- package/dist/src/utils/common/exec.d.ts +4 -0
- package/dist/src/utils/common/exec.js +52 -0
- package/dist/src/utils/common/exec.js.map +1 -0
- package/dist/src/utils/common/github.d.ts +20 -0
- package/dist/src/utils/common/github.js +60 -0
- package/dist/src/utils/common/github.js.map +1 -0
- package/dist/src/utils/common/import-esm.d.ts +2 -0
- package/dist/src/utils/common/import-esm.js +12 -0
- package/dist/src/utils/common/import-esm.js.map +1 -0
- package/dist/src/utils/common/logger.d.ts +1 -0
- package/dist/src/utils/common/logger.js +8 -0
- package/dist/src/utils/common/logger.js.map +1 -0
- package/dist/src/utils/common/nx.d.ts +22 -0
- package/dist/src/utils/common/nx.js +174 -0
- package/dist/src/utils/common/nx.js.map +1 -0
- package/dist/src/utils/common/s3.d.ts +1 -0
- package/dist/src/utils/common/s3.js +18 -0
- package/dist/src/utils/common/s3.js.map +1 -0
- package/dist/src/utils/common/tsh.d.ts +11 -0
- package/dist/src/utils/common/tsh.js +112 -0
- package/dist/src/utils/common/tsh.js.map +1 -0
- package/dist/src/utils/datadog.d.ts +1 -0
- package/dist/src/utils/datadog.js +33 -0
- package/dist/src/utils/datadog.js.map +1 -0
- package/dist/src/utils/docker.d.ts +15 -0
- package/dist/src/utils/docker.js +73 -0
- package/dist/src/utils/docker.js.map +1 -0
- package/dist/src/utils/helm.d.ts +64 -0
- package/dist/src/utils/helm.js +159 -0
- package/dist/src/utils/helm.js.map +1 -0
- package/dist/src/utils/helm.mock.d.ts +85 -0
- package/dist/src/utils/helm.mock.js +100 -0
- package/dist/src/utils/helm.mock.js.map +1 -0
- package/dist/src/utils/lambda/aws-lambda.d.ts +47 -0
- package/dist/src/utils/lambda/aws-lambda.js +231 -0
- package/dist/src/utils/lambda/aws-lambda.js.map +1 -0
- package/dist/src/utils/lambda/lambda.d.ts +7 -0
- package/dist/src/utils/lambda/lambda.js +20 -0
- package/dist/src/utils/lambda/lambda.js.map +1 -0
- package/dist/src/utils/lambda/oci.d.ts +8 -0
- package/dist/src/utils/lambda/oci.js +22 -0
- package/dist/src/utils/lambda/oci.js.map +1 -0
- package/dist/src/utils/lambda/publish.d.ts +14 -0
- package/dist/src/utils/lambda/publish.js +44 -0
- package/dist/src/utils/lambda/publish.js.map +1 -0
- package/dist/src/utils/lambda/spacelift.d.ts +3 -0
- package/dist/src/utils/lambda/spacelift.js +55 -0
- package/dist/src/utils/lambda/spacelift.js.map +1 -0
- package/dist/src/utils/spacelift/lib/__generated__/fragment-masking.d.ts +19 -0
- package/dist/src/utils/spacelift/lib/__generated__/fragment-masking.js +22 -0
- package/dist/src/utils/spacelift/lib/__generated__/fragment-masking.js.map +1 -0
- package/dist/src/utils/spacelift/lib/__generated__/gql.d.ts +15 -0
- package/dist/src/utils/spacelift/lib/__generated__/gql.js +8 -0
- package/dist/src/utils/spacelift/lib/__generated__/gql.js.map +1 -0
- package/dist/src/utils/spacelift/lib/__generated__/graphql.d.ts +9426 -0
- package/dist/src/utils/spacelift/lib/__generated__/graphql.js +819 -0
- package/dist/src/utils/spacelift/lib/__generated__/graphql.js.map +1 -0
- package/dist/src/utils/spacelift/lib/__generated__/index.d.ts +2 -0
- package/dist/src/utils/spacelift/lib/__generated__/index.js +6 -0
- package/dist/src/utils/spacelift/lib/__generated__/index.js.map +1 -0
- package/dist/src/utils/spacelift/lib/graphql.service.d.ts +18 -0
- package/dist/src/utils/spacelift/lib/graphql.service.js +186 -0
- package/dist/src/utils/spacelift/lib/graphql.service.js.map +1 -0
- package/dist/src/utils/spacelift/lib/query/spacelift.queries.d.ts +34 -0
- package/dist/src/utils/spacelift/lib/query/spacelift.queries.js +48 -0
- package/dist/src/utils/spacelift/lib/query/spacelift.queries.js.map +1 -0
- package/dist/src/utils/spacelift/lib/spacelift.error.d.ts +43 -0
- package/dist/src/utils/spacelift/lib/spacelift.error.js +63 -0
- package/dist/src/utils/spacelift/lib/spacelift.error.js.map +1 -0
- package/dist/src/utils/spacelift/lib/spacelift.service.d.ts +16 -0
- package/dist/src/utils/spacelift/lib/spacelift.service.js +58 -0
- package/dist/src/utils/spacelift/lib/spacelift.service.js.map +1 -0
- package/dist/src/utils/spacelift/lib/utils.d.ts +4 -0
- package/dist/src/utils/spacelift/lib/utils.js +32 -0
- package/dist/src/utils/spacelift/lib/utils.js.map +1 -0
- package/executors.json +19 -0
- package/generators.json +9 -0
- package/package.json +60 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxFns = exports.getAffectedProjectCliWithFilters = void 0;
|
|
4
|
+
exports.getDistForApp = getDistForApp;
|
|
5
|
+
exports.getVersion = getVersion;
|
|
6
|
+
exports.getAffectedProjects = getAffectedProjects;
|
|
7
|
+
const fs = require("node:fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
11
|
+
const exec_1 = require("./exec");
|
|
12
|
+
const logger_1 = require("./logger");
|
|
13
|
+
/**
|
|
14
|
+
* Read and return the Nx workspace nx.json configuration if present.
|
|
15
|
+
*/
|
|
16
|
+
function readNxJsonConfig() {
|
|
17
|
+
try {
|
|
18
|
+
const nxJsonPath = (0, path_1.join)(devkit_1.workspaceRoot, 'nx.json');
|
|
19
|
+
if (!fs.existsSync(nxJsonPath))
|
|
20
|
+
return undefined;
|
|
21
|
+
return (0, devkit_1.readJsonFile)(nxJsonPath);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
logger_1.consola.error('Failed to read nx.json configuration:', error);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function getDistForApp(context) {
|
|
29
|
+
const target = (0, devkit_1.parseTargetString)('build', context);
|
|
30
|
+
const project = context.projectGraph.nodes[target.project].data;
|
|
31
|
+
const buildTarget = project.targets[target.target];
|
|
32
|
+
let maybeOutputPath = buildTarget.outputs?.[0] ??
|
|
33
|
+
buildTarget.options.outputPath ??
|
|
34
|
+
buildTarget.options.outputDir;
|
|
35
|
+
maybeOutputPath = (0, utils_1.interpolate)(maybeOutputPath, {
|
|
36
|
+
workspaceRoot: devkit_1.workspaceRoot,
|
|
37
|
+
projectRoot: project.root,
|
|
38
|
+
projectName: project.name,
|
|
39
|
+
options: {
|
|
40
|
+
...(buildTarget.options ?? {}),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
if (!maybeOutputPath) {
|
|
44
|
+
throw new Error('No dist location found, something is very wrong');
|
|
45
|
+
}
|
|
46
|
+
const outputDir = normalizeOutputPath(maybeOutputPath);
|
|
47
|
+
if (!fs.existsSync(outputDir)) {
|
|
48
|
+
throw new Error(`No build found at ${outputDir}. You should build ${project.name} first`);
|
|
49
|
+
}
|
|
50
|
+
return outputDir;
|
|
51
|
+
}
|
|
52
|
+
function normalizeOutputPath(outputPath) {
|
|
53
|
+
if (!outputPath.startsWith(devkit_1.workspaceRoot)) {
|
|
54
|
+
outputPath = (0, path_1.join)(devkit_1.workspaceRoot, outputPath);
|
|
55
|
+
}
|
|
56
|
+
if (!fs.lstatSync(outputPath).isDirectory()) {
|
|
57
|
+
outputPath = (0, path_1.dirname)(outputPath);
|
|
58
|
+
}
|
|
59
|
+
return outputPath;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the manifest roots to update from the project configuration
|
|
63
|
+
* @param context ExecutorContext
|
|
64
|
+
* @returns Array of absolute paths to manifest root directories
|
|
65
|
+
*/
|
|
66
|
+
function getManifestRootsToUpdate(context) {
|
|
67
|
+
const projectConfig = context.projectsConfigurations.projects[context.projectName];
|
|
68
|
+
const projectGraphData = context.projectGraph.nodes[context.projectName]?.data;
|
|
69
|
+
const nxConfig = context.nxJsonConfiguration;
|
|
70
|
+
// Try to get manifestRootsToUpdate from project-specific config first
|
|
71
|
+
let manifestRoots = projectConfig?.release?.version
|
|
72
|
+
?.manifestRootsToUpdate;
|
|
73
|
+
// Fall back to nx.json configuration
|
|
74
|
+
if (!manifestRoots) {
|
|
75
|
+
manifestRoots = nxConfig?.release?.version?.manifestRootsToUpdate;
|
|
76
|
+
}
|
|
77
|
+
// Default to project root if no configuration found
|
|
78
|
+
if (!manifestRoots) {
|
|
79
|
+
manifestRoots = ['{projectRoot}'];
|
|
80
|
+
}
|
|
81
|
+
// Interpolate paths and convert to absolute paths
|
|
82
|
+
return manifestRoots.map(root => {
|
|
83
|
+
// Handle both string and object formats
|
|
84
|
+
const rootPath = typeof root === 'string' ? root : root.path;
|
|
85
|
+
// Interpolate placeholders
|
|
86
|
+
const interpolatedPath = (0, utils_1.interpolate)(rootPath, {
|
|
87
|
+
workspaceRoot: devkit_1.workspaceRoot,
|
|
88
|
+
projectRoot: projectGraphData?.root || '',
|
|
89
|
+
projectName: context.projectName || '',
|
|
90
|
+
options: {},
|
|
91
|
+
});
|
|
92
|
+
return normalizeOutputPath(interpolatedPath);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the version of a project by reading from manifestRootsToUpdate
|
|
97
|
+
* @param context ExecutorContext containing merged configuration
|
|
98
|
+
* @returns {string | null} The project version from manifest files or null if not found
|
|
99
|
+
*/
|
|
100
|
+
function getVersion(context) {
|
|
101
|
+
const manifestRoot = getManifestRootsToUpdate(context)[0];
|
|
102
|
+
const packageJsonPath = (0, path_1.join)(manifestRoot, 'package.json');
|
|
103
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
104
|
+
try {
|
|
105
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
106
|
+
return packageJson.version || null;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
throw new Error(`Failed to retrieve version from package.json at ${packageJsonPath}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Invoke Nx CLI to fetch affected projects with optional include/exclude filters.
|
|
116
|
+
*/
|
|
117
|
+
const getAffectedProjectCliWithFilters = async (includes, excludes) => {
|
|
118
|
+
const args = [
|
|
119
|
+
'npx nx show projects --affected --with-target="nx-release-publish" --json',
|
|
120
|
+
];
|
|
121
|
+
if (includes && includes.length > 0) {
|
|
122
|
+
args.push(`--projects="${includes.join(',')}"`);
|
|
123
|
+
}
|
|
124
|
+
if (excludes && excludes.length > 0) {
|
|
125
|
+
args.push(`--exclude="${excludes.join(',')}"`);
|
|
126
|
+
}
|
|
127
|
+
return (0, exec_1.exec)(args.join(' '), {
|
|
128
|
+
throwOnError: true,
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
exports.getAffectedProjectCliWithFilters = getAffectedProjectCliWithFilters;
|
|
132
|
+
// Export a container to enable clean spying/mocking in tests while keeping functions local
|
|
133
|
+
exports.nxFns = { getAffectedProjectCliWithFilters: exports.getAffectedProjectCliWithFilters };
|
|
134
|
+
/**
|
|
135
|
+
* Get the list of currently affected projects that have the nx-release-publish target (which make them publishable)
|
|
136
|
+
* and are included in the release configuration.
|
|
137
|
+
*
|
|
138
|
+
* @param releaseGroups
|
|
139
|
+
*/
|
|
140
|
+
async function getAffectedProjects(releaseGroups) {
|
|
141
|
+
const includes = [];
|
|
142
|
+
const excludes = [];
|
|
143
|
+
let patterns = [];
|
|
144
|
+
const nxConfig = readNxJsonConfig();
|
|
145
|
+
// Get patterns list
|
|
146
|
+
// No groups: just return affected projects with the target
|
|
147
|
+
if (!releaseGroups || releaseGroups.length === 0) {
|
|
148
|
+
// If global release.projects is configured, honor it
|
|
149
|
+
if (nxConfig?.release?.projects.length > 0) {
|
|
150
|
+
patterns = patterns.concat(nxConfig?.release?.projects);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Read nx.json
|
|
155
|
+
const nxConfig = readNxJsonConfig();
|
|
156
|
+
// Collect include/exclude patterns across release groups
|
|
157
|
+
const releaseGroupsConfig = nxConfig?.release?.groups || {};
|
|
158
|
+
for (const group of releaseGroups) {
|
|
159
|
+
patterns = patterns.concat(releaseGroupsConfig[group]?.projects);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
for (const p of patterns) {
|
|
163
|
+
if (typeof p !== 'string')
|
|
164
|
+
continue;
|
|
165
|
+
if (p.startsWith('!'))
|
|
166
|
+
excludes.push(p.substring(1)); // remove the '!' character
|
|
167
|
+
else
|
|
168
|
+
includes.push(p);
|
|
169
|
+
}
|
|
170
|
+
const normalizedIncludes = includes.length > 0 ? includes : ['*'];
|
|
171
|
+
const result = await exports.nxFns.getAffectedProjectCliWithFilters(normalizedIncludes, excludes);
|
|
172
|
+
return JSON.parse(result.stdout);
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=nx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,eAAe;QACf,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAA;QACnC,yDAAyD;QACzD,MAAM,mBAAmB,GAAG,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,CAAA;QAC3D,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAA;QAClE,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,SAAQ;QACnC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;YACnB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,2BAA2B;;YACtD,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvB,CAAC;IACD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACjE,MAAM,MAAM,GAAG,MAAM,aAAK,CAAC,gCAAgC,CACzD,kBAAkB,EAClB,QAAQ,CACT,CAAA;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pushToS3(source: string, targetS3FileName: string): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pushToS3 = pushToS3;
|
|
4
|
+
const aws_auth_1 = require("./aws-auth");
|
|
5
|
+
const exec_1 = require("./exec");
|
|
6
|
+
async function pushToS3(source, targetS3FileName) {
|
|
7
|
+
if (!source || !targetS3FileName) {
|
|
8
|
+
throw new Error('Missing source or target for s3 cp');
|
|
9
|
+
}
|
|
10
|
+
const bucketName = targetS3FileName.split('/')[0];
|
|
11
|
+
const fileName = targetS3FileName.split('/').slice(1).join('/');
|
|
12
|
+
const profile = (0, aws_auth_1.getProfileName)() === 'default' ? '' : `--profile ${(0, aws_auth_1.getProfileName)()}`;
|
|
13
|
+
await (0, exec_1.exec)(`aws s3 cp ${profile} --sse AES256 ${source} s3://${targetS3FileName}`, { throwOnError: true });
|
|
14
|
+
if (targetS3FileName.includes('ephemeral')) {
|
|
15
|
+
await (0, exec_1.exec)(`aws s3api put-object-tagging ${profile} --bucket ${bucketName} --key ${fileName} --tagging '{"TagSet": [{ "Key": "auto-purge", "Value": "true" }]}'`, { throwOnError: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=s3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.js","sourceRoot":"","sources":["../../../../src/utils/common/s3.ts"],"names":[],"mappings":";;AAGA,4BAqBC;AAxBD,yCAA2C;AAC3C,iCAA6B;AAEtB,KAAK,UAAU,QAAQ,CAAC,MAAc,EAAE,gBAAwB;IACrE,IAAI,CAAC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAE/D,MAAM,OAAO,GACX,IAAA,yBAAc,GAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAA,yBAAc,GAAE,EAAE,CAAA;IAEvE,MAAM,IAAA,WAAI,EACR,aAAa,OAAO,iBAAiB,MAAM,SAAS,gBAAgB,EAAE,EACtE,EAAE,YAAY,EAAE,IAAI,EAAE,CACvB,CAAA;IACD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAA,WAAI,EACR,gCAAgC,OAAO,aAAa,UAAU,UAAU,QAAQ,qEAAqE,EACrJ,EAAE,YAAY,EAAE,IAAI,EAAE,CACvB,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function isLoggedInToTsh(): Promise<boolean>;
|
|
2
|
+
export declare function ensureIsLoggedInToTsh(): Promise<boolean>;
|
|
3
|
+
export declare function isConnectedToChartMuseum(): Promise<boolean>;
|
|
4
|
+
export declare function ensureAppIsChartMuseum(): Promise<boolean>;
|
|
5
|
+
export declare const getLocalPortForChartMuseum: () => Promise<{
|
|
6
|
+
[Symbol.dispose]: () => Promise<void>;
|
|
7
|
+
fetchClient: import("ky").KyInstance;
|
|
8
|
+
isReady: () => Promise<boolean>;
|
|
9
|
+
port: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function startTbot(): Promise<import("tinyexec").Output>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLocalPortForChartMuseum = void 0;
|
|
4
|
+
exports.isLoggedInToTsh = isLoggedInToTsh;
|
|
5
|
+
exports.ensureIsLoggedInToTsh = ensureIsLoggedInToTsh;
|
|
6
|
+
exports.isConnectedToChartMuseum = isConnectedToChartMuseum;
|
|
7
|
+
exports.ensureAppIsChartMuseum = ensureAppIsChartMuseum;
|
|
8
|
+
exports.startTbot = startTbot;
|
|
9
|
+
const workspace_root_1 = require("nx/src/utils/workspace-root");
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const exec_1 = require("./exec");
|
|
12
|
+
const import_esm_1 = require("./import-esm");
|
|
13
|
+
const logger_1 = require("./logger");
|
|
14
|
+
const expectedProfileUrl = 'https://payfit.teleport.sh:443';
|
|
15
|
+
const expectedAppName = 'charts-shared';
|
|
16
|
+
const profile = zod_1.z.object({
|
|
17
|
+
profile_url: zod_1.z.string(),
|
|
18
|
+
});
|
|
19
|
+
const statusSchema = zod_1.z.object({
|
|
20
|
+
active: profile,
|
|
21
|
+
profiles: zod_1.z.array(profile).optional(),
|
|
22
|
+
});
|
|
23
|
+
const getStatusOfTsh = async () => {
|
|
24
|
+
const { stdout } = await (0, exec_1.exec)('tsh status -f json');
|
|
25
|
+
return statusSchema.parse(JSON.parse(stdout));
|
|
26
|
+
};
|
|
27
|
+
async function isLoggedInToTsh() {
|
|
28
|
+
try {
|
|
29
|
+
const status = await getStatusOfTsh();
|
|
30
|
+
return status.active.profile_url === expectedProfileUrl;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function ensureIsLoggedInToTsh() {
|
|
37
|
+
if (await isLoggedInToTsh()) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
await (0, exec_1.exec)(`tsh login --proxy=${expectedProfileUrl} --auth=okta`);
|
|
41
|
+
return await isLoggedInToTsh();
|
|
42
|
+
}
|
|
43
|
+
const getAppConfigOfTsh = async () => {
|
|
44
|
+
const { stdout } = await (0, exec_1.exec)(`tsh apps config -f json --proxy=${expectedProfileUrl} ${expectedAppName}`);
|
|
45
|
+
return JSON.parse(stdout);
|
|
46
|
+
};
|
|
47
|
+
async function isConnectedToChartMuseum() {
|
|
48
|
+
try {
|
|
49
|
+
const apps = await getAppConfigOfTsh();
|
|
50
|
+
return apps.name === expectedAppName;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function ensureAppIsChartMuseum() {
|
|
57
|
+
if (await isConnectedToChartMuseum()) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
await (0, exec_1.exec)(`tsh apps login ${expectedAppName} --proxy=${expectedProfileUrl}`);
|
|
61
|
+
return await isConnectedToChartMuseum();
|
|
62
|
+
}
|
|
63
|
+
const getLocalPortForChartMuseum = async () => {
|
|
64
|
+
if (!process.env.CI) {
|
|
65
|
+
await ensureIsLoggedInToTsh();
|
|
66
|
+
await ensureAppIsChartMuseum();
|
|
67
|
+
}
|
|
68
|
+
const { default: getPort } = await (0, import_esm_1.importGetPort)();
|
|
69
|
+
const { default: ky } = await (0, import_esm_1.importKy)();
|
|
70
|
+
const port = await getPort();
|
|
71
|
+
const command = process.env.CI
|
|
72
|
+
? `tsh -i ./certs/identity --proxy payfit.teleport.sh:443 proxy app ${expectedAppName} --port ${port}`
|
|
73
|
+
: `tsh proxy app ${expectedAppName} -p ${port}`;
|
|
74
|
+
const execHandle = (0, exec_1.exec)(command, {
|
|
75
|
+
throwOnError: true,
|
|
76
|
+
nodeOptions: {
|
|
77
|
+
cwd: workspace_root_1.workspaceRoot,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const isReady = async () => {
|
|
81
|
+
for await (const line of execHandle) {
|
|
82
|
+
logger_1.consola.log(`[TSH] ${line}`);
|
|
83
|
+
if (line.includes('Proxying connections')) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// line will be from stderr/stdout in the order you'd see it in a term
|
|
88
|
+
return false;
|
|
89
|
+
};
|
|
90
|
+
const fetchClient = ky.create({
|
|
91
|
+
prefixUrl: `http://localhost:${port}`,
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
[Symbol.dispose]: async () => {
|
|
95
|
+
logger_1.consola.log(`Terminating tsh proxy on port ${port}`);
|
|
96
|
+
execHandle.kill();
|
|
97
|
+
},
|
|
98
|
+
fetchClient,
|
|
99
|
+
isReady,
|
|
100
|
+
port,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
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
|
+
//# sourceMappingURL=tsh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsh.js","sourceRoot":"","sources":["../../../../src/utils/common/tsh.ts"],"names":[],"mappings":";;;AAwBA,0CAOC;AAED,sDAMC;AASD,4DAOC;AAED,wDAMC;AAgDD,8BAUC;AAzHD,gEAA2D;AAC3D,6BAAuB;AAEvB,iCAA6B;AAC7B,6CAAsD;AACtD,qCAAkC;AAElC,MAAM,kBAAkB,GAAG,gCAAgC,CAAA;AAC3D,MAAM,eAAe,GAAG,eAAe,CAAA;AAEvC,MAAM,OAAO,GAAG,OAAC,CAAC,MAAM,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,WAAI,EAAC,oBAAoB,CAAC,CAAA;IACnD,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA;AAEM,KAAK,UAAU,eAAe;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CAAC,CAAA;AA5CY,QAAA,0BAA0B,8BA4CtC;AAEM,KAAK,UAAU,SAAS;IAC7B,OAAO,IAAA,WAAI,EACT,iBAAiB,8BAAa,wCAAwC,EACtE;QACE,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE;YACX,KAAK,EAAE,SAAS;SACjB;KACF,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function correlateDeploymentImage(image: string, repositoryUrl: string, commitSha: string): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.correlateDeploymentImage = correlateDeploymentImage;
|
|
4
|
+
const logger_1 = require("./common/logger");
|
|
5
|
+
// https://docs.datadoghq.com/continuous_delivery/deployments/
|
|
6
|
+
async function correlateDeploymentImage(image, repositoryUrl, commitSha) {
|
|
7
|
+
const site = process.env.DD_SITE || 'datadoghq.com';
|
|
8
|
+
const payload = {
|
|
9
|
+
data: {
|
|
10
|
+
type: 'ci_deployment_correlate_image',
|
|
11
|
+
attributes: {
|
|
12
|
+
commit_sha: commitSha,
|
|
13
|
+
repository_url: repositoryUrl,
|
|
14
|
+
image: image,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const response = await fetch(`https://api.${site}/api/v2/ci/deployments/correlate-image`, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'DD-API-KEY': process.env.DD_API_KEY,
|
|
23
|
+
'DD-APPLICATION-KEY': process.env.DD_APP_KEY,
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify(payload),
|
|
26
|
+
});
|
|
27
|
+
if (!response.ok || response.status !== 201) {
|
|
28
|
+
logger_1.consola.warn(`Failed to correlate deployment image ${image} with commit ${commitSha} and repository ${repositoryUrl} (Datadog preview feature)`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
logger_1.consola.info(`Correlate deployment image ${image} with commit ${commitSha} and repository ${repositoryUrl} (Datadog preview feature)`);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=datadog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datadog.js","sourceRoot":"","sources":["../../../src/utils/datadog.ts"],"names":[],"mappings":";;AAGA,4DAyCC;AA5CD,4CAAyC;AAEzC,8DAA8D;AACvD,KAAK,UAAU,wBAAwB,CAC5C,KAAa,EACb,aAAqB,EACrB,SAAiB;IAEjB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,eAAe,CAAA;IAEnD,MAAM,OAAO,GAAG;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,+BAA+B;YACrC,UAAU,EAAE;gBACV,UAAU,EAAE,SAAS;gBACrB,cAAc,EAAE,aAAa;gBAC7B,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAA;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,eAAe,IAAI,wCAAwC,EAC3D;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;YACpC,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;SAC7C;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CACF,CAAA;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5C,gBAAO,CAAC,IAAI,CACV,wCAAwC,KAAK,gBAAgB,SAAS,mBAAmB,aAAa,4BAA4B,CACnI,CAAA;QACD,OAAM;IACR,CAAC;IAED,gBAAO,CAAC,IAAI,CACV,8BAA8B,KAAK,gBAAgB,SAAS,mBAAmB,aAAa,4BAA4B,CACzH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from 'tinyexec';
|
|
2
|
+
/**
|
|
3
|
+
* Builds and pushes a Docker image using the provided Dockerfile.
|
|
4
|
+
*
|
|
5
|
+
* @param imageName - The name of the image
|
|
6
|
+
* @param dockerfilePath - Path to the Dockerfile
|
|
7
|
+
* @param version - Version tag for the image
|
|
8
|
+
* @param gitRepoUrl - Git repository URL for annotations
|
|
9
|
+
* @param commitSha - Git commit SHA for annotations
|
|
10
|
+
* @param registry - Docker registry URL
|
|
11
|
+
* @param extraTags - Optional additional tags for the image
|
|
12
|
+
* @param appName
|
|
13
|
+
* @return {Promise<Result>}
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildAndPushDockerImage(imageName: string, dockerfilePath: string, version: string, gitRepoUrl: string, commitSha: string, registry: string, extraTags: string[], appName: string): Promise<Result>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAndPushDockerImage = buildAndPushDockerImage;
|
|
4
|
+
const exec_1 = require("./common/exec");
|
|
5
|
+
const logger_1 = require("./common/logger");
|
|
6
|
+
async function setupDockerBuilder(appName) {
|
|
7
|
+
const BUILDKIT_BUILDER_NAME = 'dockerContainerBuildkit'.concat(appName);
|
|
8
|
+
logger_1.consola.log(`Setting up Docker Buildx builder named ${BUILDKIT_BUILDER_NAME}...`);
|
|
9
|
+
const buildersResult = await (0, exec_1.exec)(`docker buildx ls`, {
|
|
10
|
+
throwOnError: true,
|
|
11
|
+
});
|
|
12
|
+
const hasBuildkitBuilder = buildersResult.stdout.includes(BUILDKIT_BUILDER_NAME);
|
|
13
|
+
const isBuildkitCurrentBuilder = buildersResult.stdout.includes(`${BUILDKIT_BUILDER_NAME}*`);
|
|
14
|
+
logger_1.consola.log(`Checking for existing buildx builders...`);
|
|
15
|
+
if (!hasBuildkitBuilder) {
|
|
16
|
+
// Create new buildkit builder
|
|
17
|
+
logger_1.consola.log(`Creating new buildkit builder...`);
|
|
18
|
+
await (0, exec_1.exec)(`docker buildx create \
|
|
19
|
+
--name ${BUILDKIT_BUILDER_NAME} \
|
|
20
|
+
--driver=docker-container \
|
|
21
|
+
--use`, {
|
|
22
|
+
throwOnError: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else if (!isBuildkitCurrentBuilder) {
|
|
26
|
+
logger_1.consola.log(`Existing buildkit builder found, but not current.`);
|
|
27
|
+
// Use existing buildkit builder
|
|
28
|
+
await (0, exec_1.exec)(`docker buildx use ${BUILDKIT_BUILDER_NAME}`, {
|
|
29
|
+
throwOnError: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
logger_1.consola.info(`Buildx context is set to ${BUILDKIT_BUILDER_NAME}`);
|
|
33
|
+
return BUILDKIT_BUILDER_NAME;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Builds and pushes a Docker image using the provided Dockerfile.
|
|
37
|
+
*
|
|
38
|
+
* @param imageName - The name of the image
|
|
39
|
+
* @param dockerfilePath - Path to the Dockerfile
|
|
40
|
+
* @param version - Version tag for the image
|
|
41
|
+
* @param gitRepoUrl - Git repository URL for annotations
|
|
42
|
+
* @param commitSha - Git commit SHA for annotations
|
|
43
|
+
* @param registry - Docker registry URL
|
|
44
|
+
* @param extraTags - Optional additional tags for the image
|
|
45
|
+
* @param appName
|
|
46
|
+
* @return {Promise<Result>}
|
|
47
|
+
*/
|
|
48
|
+
async function buildAndPushDockerImage(imageName, dockerfilePath, version, gitRepoUrl, commitSha, registry, extraTags = [], appName) {
|
|
49
|
+
appName = appName.replaceAll('@', '-').replaceAll('/', '-');
|
|
50
|
+
const buildContextName = await setupDockerBuilder(appName);
|
|
51
|
+
// Build all tags including base version and extra tags
|
|
52
|
+
const tagArgs = [`${version}`, ...extraTags]
|
|
53
|
+
.map(tag => `-t ${registry}/${imageName}:${tag}`)
|
|
54
|
+
.join(' ');
|
|
55
|
+
const runCmd = `docker buildx build ${tagArgs} \
|
|
56
|
+
--builder ${buildContextName} \
|
|
57
|
+
-f ${dockerfilePath} \
|
|
58
|
+
--secret id=NPM_TOKEN \
|
|
59
|
+
--push \
|
|
60
|
+
--provenance=false \
|
|
61
|
+
--annotation org.opencontainers.image.source=${gitRepoUrl} \
|
|
62
|
+
--annotation org.opencontainers.image.revision=${commitSha} \
|
|
63
|
+
--build-arg DD_GIT_REPOSITORY_URL=${gitRepoUrl} \
|
|
64
|
+
--build-arg DD_GIT_COMMIT_SHA=${commitSha} \
|
|
65
|
+
.`;
|
|
66
|
+
return (0, exec_1.exec)(runCmd, {
|
|
67
|
+
throwOnError: true,
|
|
68
|
+
nodeOptions: {
|
|
69
|
+
stdio: 'inherit',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../src/utils/docker.ts"],"names":[],"mappings":";;AA0DA,0DAoCC;AA5FD,wCAAoC;AACpC,4CAAyC;AAEzC,KAAK,UAAU,kBAAkB,CAAC,OAAe;IAC/C,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACvE,gBAAO,CAAC,GAAG,CACT,0CAA0C,qBAAqB,KAAK,CACrE,CAAA;IACD,MAAM,cAAc,GAAG,MAAM,IAAA,WAAI,EAAC,kBAAkB,EAAE;QACpD,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;IACF,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,CACvD,qBAAqB,CACtB,CAAA;IACD,MAAM,wBAAwB,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,CAC7D,GAAG,qBAAqB,GAAG,CAC5B,CAAA;IACD,gBAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;IACvD,IAAI,CAAC,kBAAkB,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AAM,EAAE;QAClB,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE;YACX,KAAK,EAAE,SAAS;SACjB;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
interface ChartConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
type: string;
|
|
5
|
+
version: string;
|
|
6
|
+
dependencies?: ChartDependency[];
|
|
7
|
+
}
|
|
8
|
+
interface ChartDependency {
|
|
9
|
+
name: string;
|
|
10
|
+
alias?: string;
|
|
11
|
+
repository: string;
|
|
12
|
+
version: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read & parse the Helm chart.yaml file
|
|
16
|
+
* @param helmFolderPath
|
|
17
|
+
*/
|
|
18
|
+
export declare function getHelmChartFile(helmFolderPath: string): Promise<ChartConfig>;
|
|
19
|
+
/**
|
|
20
|
+
* Prepare the Chart.yaml config file for the Tsh proxy
|
|
21
|
+
* @param helmFolderPath
|
|
22
|
+
* @param tshPort
|
|
23
|
+
*/
|
|
24
|
+
export declare function setupTeleportProxyHelmChartFile(helmFolderPath: string, tshPort: number): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Revert the Tsh proxy config in the Chart.yaml config file
|
|
27
|
+
* @param helmFolderPath
|
|
28
|
+
* @param tshPort
|
|
29
|
+
*/
|
|
30
|
+
export declare function resetTeleportProxyHelmChartFile(helmFolderPath: string, tshPort: number): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Install all the helm repositories defined in the Chart config
|
|
33
|
+
* @param helmFolderPath
|
|
34
|
+
*/
|
|
35
|
+
export declare function installHelmRepo(helmFolderPath: string): Promise<import("tinyexec").Output>;
|
|
36
|
+
/**
|
|
37
|
+
* Patch Docker image tag in values.yaml
|
|
38
|
+
* @param valuesConfigPath
|
|
39
|
+
* @param chartConfigPath
|
|
40
|
+
* @param version
|
|
41
|
+
*/
|
|
42
|
+
export declare function patchImageTag(valuesConfigPath: string, chartConfigPath: string, version: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Package the Helm chart
|
|
45
|
+
* @param helmFolderPath
|
|
46
|
+
* @param version
|
|
47
|
+
* @param destinationPath
|
|
48
|
+
*/
|
|
49
|
+
export declare function packageHelm(helmFolderPath: string, version: string, destinationPath: string): Promise<import("tinyexec").Output>;
|
|
50
|
+
/**
|
|
51
|
+
* Push the packaged Helm chart in the chartmuseum
|
|
52
|
+
* @param packagedHelmChartFilePath
|
|
53
|
+
* @param packagedHelmChartName
|
|
54
|
+
* @param projectName
|
|
55
|
+
* @param branch
|
|
56
|
+
*/
|
|
57
|
+
export declare function pushPackagedHelm(packagedHelmChartFilePath: string, packagedHelmChartName: string, projectName: string, branch: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Push the packaged Helm chart to an OCI-compatible ECR repository
|
|
60
|
+
* @param packagedHelmChartFilePath
|
|
61
|
+
* @param ecrRegistry
|
|
62
|
+
*/
|
|
63
|
+
export declare function pushOciPackagedHelm(packagedHelmChartFilePath: string, ecrRegistry: string): Promise<import("tinyexec").Output>;
|
|
64
|
+
export {};
|