Skip to content

Commit

Permalink
feat: allow to set the cwd in copyFromPod for use in tar
Browse files Browse the repository at this point in the history
  • Loading branch information
SayakMukhopadhyay committed Feb 15, 2023
1 parent 998e631 commit 2bb4ab7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ export class Cp {
* @param {string} containerName - The name of the container in the pod to exec the command inside.
* @param {string} srcPath - The source path in the pod
* @param {string} tgtPath - The target path in local
* @param {string} cwd - The directory that is used as the parent in the pod when downloading
*/
public async cpFromPod(
namespace: string,
podName: string,
containerName: string,
srcPath: string,
tgtPath: string,
cwd?: string,
): Promise<void> {
const tmpFile = tmp.fileSync();
const tmpFileName = tmpFile.name;
const command = ['tar', 'zcf', '-', srcPath];
const command = ['tar', 'zcf', '-'];
if (cwd) {
command.push('-C', cwd);
}
command.push(srcPath);
const writerStream = fs.createWriteStream(tmpFileName);
const errStream = new WritableStreamBuffer();
this.execInstance.exec(
Expand Down Expand Up @@ -59,7 +65,7 @@ export class Cp {
* @param {string} containerName - The name of the container in the pod to exec the command inside.
* @param {string} srcPath - The source path in local
* @param {string} tgtPath - The target path in the pod
* @param {string} cwd - The directory that is used as the parent when uploading
* @param {string} cwd - The directory that is used as the parent in the host when uploading
*/
public async cpToPod(
namespace: string,
Expand Down

5 comments on commit 2bb4ab7

@leahjlou
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SayakMukhopadhyay Hi, do you know if there is a reason this commit has not yet been included in a published package on NPM? Thanks!

@SayakMukhopadhyay
Copy link
Author

@SayakMukhopadhyay SayakMukhopadhyay commented on 2bb4ab7 Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leahjlou Nope, I am just an independent contributor. The maintainers would be able to provide info on when a new package will be published. But I have another PR #988 that I want to get merged but I am having trouble getting tests to pass. I believe there is another PR #991 that was approved but not yet merged due to some changes made after the approval. Its possible that the maintainers want these 2 PRs to be done (or at least #991) before publishing

@leahjlou
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SayakMukhopadhyay thanks for the response (and your contributions). I've tagged a maintainer in another comment and will keep an eye out. If something is blocking a release that I can help with in any way, I'd be happy to jump in.

@clintonmedbery
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the tests are not passing in #991 because some of our dependencies have critical problems. Looking to fix now.

@clintonmedbery
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry, just revisited this. This is into master. My 991 PR is into the release 1.x branch. FYI.

Please sign in to comment.