11import { stringify as toYaml } from '@std/yaml' ;
2- import { tgz } from '@deno-library/compress' ;
32import { getPodLogs } from './k8s.js' ;
43import { getSemaphore } from '@henrygd/semaphore' ;
54
6-
7-
85export 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
1411export 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 ) {
0 commit comments