Skip to content

Commit 202e8de

Browse files
authored
Update Compression (#37)
1 parent 6e73b3b commit 202e8de

File tree

4 files changed

+18
-67
lines changed

4 files changed

+18
-67
lines changed

deno.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@cliffy/command": "jsr:@cliffy/[email protected]",
2525
"@cloudydeno/kubernetes-apis": "jsr:@cloudydeno/[email protected]",
2626
"@cloudydeno/kubernetes-client": "jsr:@cloudydeno/[email protected]",
27-
"@deno-library/compress": "jsr:@deno-library/compress@^0.5.6",
2827
"@henrygd/semaphore": "jsr:@henrygd/semaphore@^0.0.2",
2928
"@std/yaml": "jsr:@std/[email protected]"
3029
}

deno.lock

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

src/logic/core.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
import { stringify as toYaml } from '@std/yaml';
2-
import { tgz } from '@deno-library/compress';
32
import { getPodLogs } from './k8s.js';
43
import { getSemaphore } from '@henrygd/semaphore';
54

6-
7-
85
export async function writeYaml(data, name, dirPath) {
96
await Deno.mkdir(dirPath, { recursive: true });
107
const filePath = `${dirPath}/${name}.yaml`;
118
await Deno.writeTextFile(filePath, toYaml(data, { skipInvalid: true }));
129
}
1310

1411
export async function preparePackage(dirPath) {
15-
const semaphore = getSemaphore("zipfile", 10);
16-
await semaphore.acquire();
1712
try {
1813
const supportPackageZip = `${dirPath}.tar.gz`;
1914
console.log('Preparing the Support Package');
20-
await tgz.compress(dirPath, supportPackageZip);
15+
const command = new Deno.Command('tar', {
16+
args: ['-czf', supportPackageZip, dirPath],
17+
});
18+
const { code, _stdout, stderr } = await command.output();
19+
20+
if (code !== 0) {
21+
console.error(new TextDecoder().decode(stderr));
22+
throw new Error(`Failed to create tar.gz file: ${supportPackageZip}. \n ${stderr}`);
23+
}
2124
console.log('Cleaning up temp directory');
2225
await Deno.remove(dirPath, { recursive: true });
2326
console.log(`\nPlease attach ${supportPackageZip} to your support ticket.`);
24-
} finally {
25-
semaphore.release();
27+
} catch (error) {
28+
console.log(error);
29+
console.log(`\nPlease manually compress the directory ${dirPath} and attach it to the support ticket.`);
2630
}
2731
}
2832

@@ -37,7 +41,7 @@ export async function processData(dirPath, k8sResources) {
3741
}
3842

3943
const semaphore = getSemaphore(k8sType, 10);
40-
console.log(`Processing Data for ${k8sType}`)
44+
console.log(`Processing Data for ${k8sType}`);
4145

4246
if (k8sType == 'pods') {
4347
for (const pod of resources.items) {

src/logic/k8s.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ export async function getPodLogs(pod) {
4040
for (const container of containers) {
4141
try {
4242
logs[container] = await coreApi
43-
.namespace(namespace)
44-
.getPodLog(podName, { container: container, timestamps: true });
43+
.namespace(namespace)
44+
.getPodLog(podName, { container: container, timestamps: true });
4545
} catch (error) {
46-
logs[container] = error
46+
logs[container] = error;
4747
}
48-
4948
}
5049
return logs;
5150
}

0 commit comments

Comments
 (0)