1
1
import { stringify as toYaml } from '@std/yaml' ;
2
- import { tgz } from '@deno-library/compress' ;
3
2
import { getPodLogs } from './k8s.js' ;
4
3
import { getSemaphore } from '@henrygd/semaphore' ;
5
4
6
-
7
-
8
5
export async function writeYaml ( data , name , dirPath ) {
9
6
await Deno . mkdir ( dirPath , { recursive : true } ) ;
10
7
const filePath = `${ dirPath } /${ name } .yaml` ;
11
8
await Deno . writeTextFile ( filePath , toYaml ( data , { skipInvalid : true } ) ) ;
12
9
}
13
10
14
11
export async function preparePackage ( dirPath ) {
15
- const semaphore = getSemaphore ( "zipfile" , 10 ) ;
16
- await semaphore . acquire ( ) ;
17
12
try {
18
13
const supportPackageZip = `${ dirPath } .tar.gz` ;
19
14
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
+ }
21
24
console . log ( 'Cleaning up temp directory' ) ;
22
25
await Deno . remove ( dirPath , { recursive : true } ) ;
23
26
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.` ) ;
26
30
}
27
31
}
28
32
@@ -37,7 +41,7 @@ export async function processData(dirPath, k8sResources) {
37
41
}
38
42
39
43
const semaphore = getSemaphore ( k8sType , 10 ) ;
40
- console . log ( `Processing Data for ${ k8sType } ` )
44
+ console . log ( `Processing Data for ${ k8sType } ` ) ;
41
45
42
46
if ( k8sType == 'pods' ) {
43
47
for ( const pod of resources . items ) {
0 commit comments