File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,23 @@ export class Cp {
18
18
* @param {string } containerName - The name of the container in the pod to exec the command inside.
19
19
* @param {string } srcPath - The source path in the pod
20
20
* @param {string } tgtPath - The target path in local
21
+ * @param {string } cwd - The directory that is used as the parent in the pod when downloading
21
22
*/
22
23
public async cpFromPod (
23
24
namespace : string ,
24
25
podName : string ,
25
26
containerName : string ,
26
27
srcPath : string ,
27
28
tgtPath : string ,
29
+ cwd ?: string ,
28
30
) : Promise < void > {
29
31
const tmpFile = tmp . fileSync ( ) ;
30
32
const tmpFileName = tmpFile . name ;
31
- const command = [ 'tar' , 'zcf' , '-' , srcPath ] ;
33
+ const command = [ 'tar' , 'zcf' , '-' ] ;
34
+ if ( cwd ) {
35
+ command . push ( '-C' , cwd ) ;
36
+ }
37
+ command . push ( srcPath ) ;
32
38
const writerStream = fs . createWriteStream ( tmpFileName ) ;
33
39
const errStream = new WritableStreamBuffer ( ) ;
34
40
this . execInstance . exec (
@@ -59,7 +65,7 @@ export class Cp {
59
65
* @param {string } containerName - The name of the container in the pod to exec the command inside.
60
66
* @param {string } srcPath - The source path in local
61
67
* @param {string } tgtPath - The target path in the pod
62
- * @param {string } cwd - The directory that is used as the parent when uploading
68
+ * @param {string } cwd - The directory that is used as the parent in the host when uploading
63
69
*/
64
70
public async cpToPod (
65
71
namespace : string ,
You can’t perform that action at this time.
0 commit comments