Skip to content

Commit 3631eda

Browse files
authored
Support Package Refresh 2024-01a (#20)
- removed the cleanup of test pipeline - changed compression to tar.gz
1 parent 918d656 commit 3631eda

File tree

3 files changed

+53
-52
lines changed

3 files changed

+53
-52
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"compile": "deno task pre-compile && deno task compile:linux && deno task compile:windows && deno task compile:apple && deno task compile:apple_arm64"
2121
},
2222
"imports": {
23-
"@fakoua/zip-ts": "jsr:@fakoua/zip-ts@^1.3.1",
23+
"@deno-library/compress": "jsr:@deno-library/compress@^0.5.5",
2424
"@henrygd/semaphore": "jsr:@henrygd/semaphore@^0.0.2",
2525
"@std/yaml": "jsr:@std/yaml@^1.0.5"
2626
}

deno.lock

Lines changed: 46 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.js

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
2-
import { compress } from '@fakoua/zip-ts';
2+
3+
import { tgz } from "jsr:@deno-library/compress";
34
import { parse, stringify as toYaml } from '@std/yaml';
45
import { getSemaphore } from '@henrygd/semaphore';
56

@@ -13,7 +14,7 @@ const cfRuntimeTypes = {
1314

1415
const timestamp = new Date().getTime();
1516
const dirPath = `./codefresh-support-${timestamp}`;
16-
const supportPackageZip = `./codefresh-support-package-${timestamp}.zip`;
17+
const supportPackageZip = `./codefresh-support-package-${timestamp}.tar.gz`;
1718
const numOfProcesses = 5;
1819

1920
// ##############################
@@ -190,7 +191,7 @@ async function getAccountRuntimes(cfConfig) {
190191
async function runTestPipeline(cfConfig, runtimeName) {
191192
let selection = String(
192193
prompt(
193-
'\nTo troubleshoot, we would like to create a Demo Pipeline and run it.\nAfter creating this pipeline we will clean up the resources\n\nWould you like to proceed with the demo pipeline? (y/n): ',
194+
'\nTo troubleshoot, we would like to create a Demo Pipeline and run it.\n\nWould you like to proceed with the demo pipeline? (y/n): ',
194195
),
195196
);
196197
while (selection !== 'y' && selection !== 'n') {
@@ -206,7 +207,7 @@ async function runTestPipeline(cfConfig, runtimeName) {
206207
const projectName = 'CODEFRESH-SUPPORT-PACKAGE';
207208
const pipelineName = 'TEST-PIPELINE-FOR-SUPPORT';
208209
const pipelineYaml =
209-
'version: "1.0"\n\nsteps:\n\n test:\n title: Running test\n type: freestyle\n arguments:\n image: alpine\n commands:\n - echo "Hello Test"';
210+
'version: "1.0"\n\nsteps:\n\n freestyle:\n title: Running test\n type: freestyle\n arguments:\n image: alpine\n commands:\n - echo "Hello Test"';
210211

211212
const project = JSON.stringify({
212213
projectName: projectName,
@@ -240,8 +241,6 @@ async function runTestPipeline(cfConfig, runtimeName) {
240241
const projectStatus = await createProjectResponse.json();
241242

242243
if (!createProjectResponse.ok) {
243-
console.error('Error creating project:', createProjectResponse.statusText);
244-
console.error(projectStatus);
245244
const getProjectID = await fetch(`${cfConfig.baseUrl}/projects/name/${projectName}`, {
246245
method: 'GET',
247246
headers: cfConfig.headers,
@@ -263,8 +262,6 @@ async function runTestPipeline(cfConfig, runtimeName) {
263262

264263
if (!createPipelineResponse.ok) {
265264
try {
266-
console.error('Error creating pipeline:', createPipelineResponse.statusText);
267-
console.error(pipelineStatus);
268265
const getPipelineID = await fetch(`${cfConfig.baseUrl}/pipelines/${projectName}%2f${pipelineName}`, {
269266
method: 'GET',
270267
headers: cfConfig.headers,
@@ -316,27 +313,6 @@ async function runTestPipeline(cfConfig, runtimeName) {
316313
return { pipelineID: pipelineStatus.metadata.id, projectID: projectStatus.id, buildID: runPipelineStatus };
317314
}
318315

319-
async function deleteTestPipeline(cfConfig, pipelineID, projectID) {
320-
const deletePipelineResponse = await fetch(`${cfConfig.baseUrl}/pipelines/${pipelineID}`, {
321-
method: 'DELETE',
322-
headers: cfConfig.headers,
323-
});
324-
325-
if (!deletePipelineResponse.ok) {
326-
throw new Error('Error deleting pipeline:', await deletePipelineResponse.text());
327-
}
328-
329-
const deleteProjectResponse = await fetch(`${cfConfig.baseUrl}/projects/${projectID}`, {
330-
method: 'DELETE',
331-
headers: cfConfig.headers,
332-
});
333-
334-
if (!deleteProjectResponse.ok) {
335-
throw new Error('Error deleting project:', await deleteProjectResponse.text());
336-
}
337-
338-
console.log('Demo pipeline and project deleted successfully.');
339-
}
340316

341317
async function gatherPipelinesRuntime(cfConfig) {
342318
try {
@@ -382,7 +358,6 @@ async function gatherPipelinesRuntime(cfConfig) {
382358

383359
if (pipelineExecutionOutput) {
384360
await Deno.writeTextFile(`${dirPath}/testPipelineBuildId.txt`, pipelineExecutionOutput.buildID);
385-
await deleteTestPipeline(cfConfig, pipelineExecutionOutput.pipelineID, pipelineExecutionOutput.projectID);
386361
}
387362

388363
await prepareAndCleanup();
@@ -498,7 +473,7 @@ async function writeGetApiCalls(resources, k8sType) {
498473

499474
async function prepareAndCleanup() {
500475
console.log(`Saving data to ${supportPackageZip}`);
501-
await compress(dirPath, `${supportPackageZip}`, { overwrite: true });
476+
await tgz.compress(dirPath, supportPackageZip);
502477

503478
console.log('Cleaning up temp directory');
504479
await Deno.remove(dirPath, { recursive: true });

0 commit comments

Comments
 (0)