@@ -45,7 +45,7 @@ interface TDirectoryData {directory: boolean; owner: string; group: string; size
45
45
*/
46
46
export class K8 {
47
47
static PodReadyCondition = new Map < string , string > ( )
48
- . set ( constants . POD_CONDITION_READY , constants . POD_CONDITION_STATUS_TRUE )
48
+ . set ( constants . POD_CONDITION_READY , constants . POD_CONDITION_STATUS_TRUE )
49
49
private kubeConfig ! : k8s . KubeConfig
50
50
kubeClient ! : k8s . CoreV1Api
51
51
private coordinationApiClient : k8s . CoordinationV1Api
@@ -76,7 +76,7 @@ export class K8 {
76
76
77
77
if ( ! this . kubeConfig . getCurrentContext ( ) ) {
78
78
throw new SoloError ( 'No active kubernetes context found. ' +
79
- 'Please set current kubernetes context.' )
79
+ 'Please set current kubernetes context.' )
80
80
}
81
81
82
82
if ( ! this . kubeConfig . getCurrentCluster ( ) ) {
@@ -238,12 +238,12 @@ export class K8 {
238
238
const ns = this . _getNamespace ( )
239
239
const labelSelector = labels . join ( ',' )
240
240
const result = await this . kubeClient . listNamespacedSecret (
241
- ns ,
242
- undefined ,
243
- undefined ,
244
- undefined ,
245
- undefined ,
246
- labelSelector
241
+ ns ,
242
+ undefined ,
243
+ undefined ,
244
+ undefined ,
245
+ undefined ,
246
+ labelSelector
247
247
)
248
248
249
249
return result . body . items
@@ -442,17 +442,17 @@ export class K8 {
442
442
*/
443
443
async hasDir ( podName : string , containerName : string , destPath : string ) {
444
444
return await this . execContainer (
445
- podName ,
446
- containerName ,
447
- [ 'bash' , '-c' , '[[ -d "' + destPath + '" ]] && echo -n "true" || echo -n "false"' ]
445
+ podName ,
446
+ containerName ,
447
+ [ 'bash' , '-c' , '[[ -d "' + destPath + '" ]] && echo -n "true" || echo -n "false"' ]
448
448
) === 'true'
449
449
}
450
450
451
451
mkdir ( podName : PodName , containerName : string , destPath : string ) {
452
452
return this . execContainer (
453
- podName ,
454
- containerName ,
455
- [ 'bash' , '-c' , 'mkdir -p "' + destPath + '"' ]
453
+ podName ,
454
+ containerName ,
455
+ [ 'bash' , '-c' , 'mkdir -p "' + destPath + '"' ]
456
456
)
457
457
}
458
458
@@ -493,7 +493,7 @@ export class K8 {
493
493
}
494
494
495
495
registerOutputPassthroughStreamOnData ( localContext : LocalContextObject , messagePrefix : string ,
496
- outputPassthroughStream : stream . PassThrough , outputFileStream : fs . WriteStream ) {
496
+ outputPassthroughStream : stream . PassThrough , outputFileStream : fs . WriteStream ) {
497
497
outputPassthroughStream . on ( 'data' , ( chunk ) => {
498
498
this . logger . debug ( `${ messagePrefix } received chunk size=${ chunk . length } ` )
499
499
const canWrite = outputFileStream . write ( chunk ) // Write chunk to file and check if buffer is full
@@ -505,7 +505,7 @@ export class K8 {
505
505
}
506
506
507
507
registerOutputFileStreamOnDrain ( localContext : LocalContextObject , messagePrefix : string ,
508
- outputPassthroughStream : stream . PassThrough , outputFileStream : fs . WriteStream ) {
508
+ outputPassthroughStream : stream . PassThrough , outputFileStream : fs . WriteStream ) {
509
509
outputFileStream . on ( 'drain' , ( ) => {
510
510
outputPassthroughStream . resume ( )
511
511
this . logger . debug ( `${ messagePrefix } stream drained, resume write` )
@@ -565,28 +565,28 @@ export class K8 {
565
565
inputStream . pipe ( inputPassthroughStream )
566
566
567
567
execInstance . exec ( namespace , podName , containerName , command , null , errPassthroughStream , inputPassthroughStream , false ,
568
- ( { status } ) => self . handleCallback ( status , localContext , messagePrefix ) )
569
- . then ( conn => {
570
- self . logger . info ( `${ messagePrefix } connection established` )
571
- localContext . connection = conn
568
+ ( { status } ) => self . handleCallback ( status , localContext , messagePrefix ) )
569
+ . then ( conn => {
570
+ self . logger . info ( `${ messagePrefix } connection established` )
571
+ localContext . connection = conn
572
572
573
- self . registerConnectionOnError ( localContext , messagePrefix , conn )
573
+ self . registerConnectionOnError ( localContext , messagePrefix , conn )
574
574
575
- self . registerConnectionOnMessage ( messagePrefix )
575
+ self . registerConnectionOnMessage ( messagePrefix )
576
576
577
- conn . on ( 'close' , ( code , reason ) => {
578
- self . logger . debug ( `${ messagePrefix } connection closed` )
579
- if ( code !== 1000 ) { // code 1000 is the success code
580
- return self . exitWithError ( localContext , `${ messagePrefix } failed with code=${ code } , reason=${ reason } ` )
581
- }
577
+ conn . on ( 'close' , ( code , reason ) => {
578
+ self . logger . debug ( `${ messagePrefix } connection closed` )
579
+ if ( code !== 1000 ) { // code 1000 is the success code
580
+ return self . exitWithError ( localContext , `${ messagePrefix } failed with code=${ code } , reason=${ reason } ` )
581
+ }
582
582
583
- // Cleanup temp file after successful copy
584
- inputPassthroughStream . end ( ) // End the passthrough stream
585
- self . _deleteTempFile ( tmpFile ) // Cleanup temp file
586
- self . logger . info ( `${ messagePrefix } Successfully copied!` )
587
- return resolve ( true )
588
- } )
583
+ // Cleanup temp file after successful copy
584
+ inputPassthroughStream . end ( ) // End the passthrough stream
585
+ self . _deleteTempFile ( tmpFile ) // Cleanup temp file
586
+ self . logger . info ( `${ messagePrefix } Successfully copied!` )
587
+ return resolve ( true )
589
588
} )
589
+ } )
590
590
591
591
self . registerErrorStreamOnData ( localContext , errPassthroughStream )
592
592
@@ -666,59 +666,59 @@ export class K8 {
666
666
667
667
self . logger . debug ( `${ messagePrefix } running...` )
668
668
execInstance . exec (
669
- namespace ,
670
- podName ,
671
- containerName ,
672
- command ,
673
- outputFileStream ,
674
- errPassthroughStream ,
675
- null ,
676
- false ,
677
- ( { status } ) => {
678
- if ( status === 'Failure' ) {
679
- self . _deleteTempFile ( tmpFile )
680
- return self . exitWithError ( localContext , `${ messagePrefix } Failure occurred` )
681
- }
682
- self . logger . debug ( `${ messagePrefix } callback(status)=${ status } ` )
683
-
684
- } )
685
- . then ( conn => {
686
- self . logger . debug ( `${ messagePrefix } connection established` )
687
- localContext . connection = conn
669
+ namespace ,
670
+ podName ,
671
+ containerName ,
672
+ command ,
673
+ outputFileStream ,
674
+ errPassthroughStream ,
675
+ null ,
676
+ false ,
677
+ ( { status } ) => {
678
+ if ( status === 'Failure' ) {
679
+ self . _deleteTempFile ( tmpFile )
680
+ return self . exitWithError ( localContext , `${ messagePrefix } Failure occurred` )
681
+ }
682
+ self . logger . debug ( `${ messagePrefix } callback(status)=${ status } ` )
688
683
689
- conn . on ( 'error' , ( e ) => {
690
- self . _deleteTempFile ( tmpFile )
691
- return self . exitWithError ( localContext , `${ messagePrefix } failed, connection error: ${ e . message } ` )
692
- } )
684
+ } )
685
+ . then ( conn => {
686
+ self . logger . debug ( `${ messagePrefix } connection established ` )
687
+ localContext . connection = conn
693
688
694
- self . registerConnectionOnMessage ( messagePrefix )
689
+ conn . on ( 'error' , ( e ) => {
690
+ self . _deleteTempFile ( tmpFile )
691
+ return self . exitWithError ( localContext , `${ messagePrefix } failed, connection error: ${ e . message } ` )
692
+ } )
695
693
696
- conn . on ( 'close' , ( code , reason ) => {
697
- self . logger . debug ( `${ messagePrefix } connection closed` )
698
- if ( code !== 1000 ) { // code 1000 is the success code
699
- return self . exitWithError ( localContext , `${ messagePrefix } failed with code=${ code } , reason=${ reason } ` )
700
- }
694
+ self . registerConnectionOnMessage ( messagePrefix )
701
695
702
- outputFileStream . end ( )
703
- outputFileStream . close ( ( ) => {
704
- try {
705
- fs . copyFileSync ( tmpFile , destPath )
696
+ conn . on ( 'close' , ( code , reason ) => {
697
+ self . logger . debug ( `${ messagePrefix } connection closed` )
698
+ if ( code !== 1000 ) { // code 1000 is the success code
699
+ return self . exitWithError ( localContext , `${ messagePrefix } failed with code=${ code } , reason=${ reason } ` )
700
+ }
706
701
707
- self . _deleteTempFile ( tmpFile )
702
+ outputFileStream . end ( )
703
+ outputFileStream . close ( ( ) => {
704
+ try {
705
+ fs . copyFileSync ( tmpFile , destPath )
708
706
709
- const stat = fs . statSync ( destPath )
710
- if ( stat && stat . size === srcFileSize ) {
711
- self . logger . debug ( `${ messagePrefix } finished` )
712
- return resolve ( true )
713
- }
707
+ self . _deleteTempFile ( tmpFile )
714
708
715
- return self . exitWithError ( localContext , `${ messagePrefix } files did not match, srcFileSize=${ srcFileSize } , stat.size=${ stat ?. size } ` )
716
- } catch ( e : Error | any ) {
717
- return self . exitWithError ( localContext , `${ messagePrefix } failed to complete download` )
709
+ const stat = fs . statSync ( destPath )
710
+ if ( stat && stat . size === srcFileSize ) {
711
+ self . logger . debug ( `${ messagePrefix } finished` )
712
+ return resolve ( true )
718
713
}
719
- } )
714
+
715
+ return self . exitWithError ( localContext , `${ messagePrefix } files did not match, srcFileSize=${ srcFileSize } , stat.size=${ stat ?. size } ` )
716
+ } catch ( e : Error | any ) {
717
+ return self . exitWithError ( localContext , `${ messagePrefix } failed to complete download` )
718
+ }
720
719
} )
721
720
} )
721
+ } )
722
722
723
723
self . registerErrorStreamOnData ( localContext , errPassthroughStream )
724
724
@@ -771,39 +771,39 @@ export class K8 {
771
771
772
772
self . logger . debug ( `${ messagePrefix } running...` )
773
773
execInstance . exec (
774
- namespace ,
775
- podName ,
776
- containerName ,
777
- command ,
778
- outputFileStream ,
779
- errPassthroughStream ,
780
- null ,
781
- false ,
782
- ( { status } ) => self . handleCallback ( status , localContext , messagePrefix ) )
783
- . then ( conn => {
784
- self . logger . debug ( `${ messagePrefix } connection established` )
785
- localContext . connection = conn
786
-
787
- self . registerConnectionOnError ( localContext , messagePrefix , conn )
788
-
789
- self . registerConnectionOnMessage ( messagePrefix )
790
-
791
- conn . on ( 'close' , ( code , reason ) => {
792
- self . logger . debug ( `${ messagePrefix } connection closed` )
793
- if ( ! localContext . errorMessage ) {
794
- if ( code !== 1000 ) { // code 1000 is the success code
795
- return self . exitWithError ( localContext , `${ messagePrefix } failed with code=${ code } , reason=${ reason } ` )
796
- }
797
-
798
- outputFileStream . end ( )
799
- outputFileStream . close ( ( ) => {
800
- self . logger . debug ( `${ messagePrefix } finished` )
801
- const outData = fs . readFileSync ( tmpFile )
802
- return resolve ( outData . toString ( ) )
803
- } )
774
+ namespace ,
775
+ podName ,
776
+ containerName ,
777
+ command ,
778
+ outputFileStream ,
779
+ errPassthroughStream ,
780
+ null ,
781
+ false ,
782
+ ( { status } ) => self . handleCallback ( status , localContext , messagePrefix ) )
783
+ . then ( conn => {
784
+ self . logger . debug ( `${ messagePrefix } connection established` )
785
+ localContext . connection = conn
786
+
787
+ self . registerConnectionOnError ( localContext , messagePrefix , conn )
788
+
789
+ self . registerConnectionOnMessage ( messagePrefix )
790
+
791
+ conn . on ( 'close' , ( code , reason ) => {
792
+ self . logger . debug ( `${ messagePrefix } connection closed` )
793
+ if ( ! localContext . errorMessage ) {
794
+ if ( code !== 1000 ) { // code 1000 is the success code
795
+ return self . exitWithError ( localContext , `${ messagePrefix } failed with code=${ code } , reason=${ reason } ` )
804
796
}
805
- } )
797
+
798
+ outputFileStream . end ( )
799
+ outputFileStream . close ( ( ) => {
800
+ self . logger . debug ( `${ messagePrefix } finished` )
801
+ const outData = fs . readFileSync ( tmpFile )
802
+ return resolve ( outData . toString ( ) )
803
+ } )
804
+ }
806
805
} )
806
+ } )
807
807
808
808
self . registerErrorStreamOnData ( localContext , errPassthroughStream )
809
809
@@ -1115,17 +1115,17 @@ export class K8 {
1115
1115
*/
1116
1116
async getSecret ( namespace : string , labelSelector : string ) {
1117
1117
const result = await this . kubeClient . listNamespacedSecret (
1118
- namespace ,
1119
- undefined ,
1120
- undefined ,
1121
- undefined ,
1122
- undefined ,
1123
- labelSelector ,
1124
- undefined ,
1125
- undefined ,
1126
- undefined ,
1127
- undefined ,
1128
- 5 * MINUTES
1118
+ namespace ,
1119
+ undefined ,
1120
+ undefined ,
1121
+ undefined ,
1122
+ undefined ,
1123
+ labelSelector ,
1124
+ undefined ,
1125
+ undefined ,
1126
+ undefined ,
1127
+ undefined ,
1128
+ 5 * MINUTES
1129
1129
)
1130
1130
1131
1131
if ( result . response . statusCode === 200 && result . body . items && result . body . items . length > 0 ) {
0 commit comments