Skip to content

Move to tar-fs. #2402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"socks-proxy-agent": "^8.0.4",
"stream-buffers": "^3.0.2",
"tar": "^7.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

tar should be removed from this file and package-lock.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

"tar-fs": "^3.0.8",
"tmp-promise": "^3.0.2",
"ws": "^8.18.0"
},
Expand Down
22 changes: 6 additions & 16 deletions src/cp.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import fs from 'node:fs';
import fs, { rmSync } from 'node:fs';

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 23 validation

'fs' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 23 validation

'rmSync' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 22 validation

'fs' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 22 validation

'rmSync' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 20 validation

'fs' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 20 validation

'rmSync' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 18 validation

'fs' is defined but never used

Check failure on line 1 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 18 validation

'rmSync' is defined but never used
import { WritableStreamBuffer } from 'stream-buffers';
import * as tar from 'tar';
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some linter errors in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

import tar from 'tar-fs';
import tmp from 'tmp-promise';
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the back and forth - I think this is the only use of this dependency in the project. If it's removed here, it can be removed from package.json and package-lock.json too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (and removed ws also since it is not a direct dependency)

import path from 'node:path';

Check failure on line 5 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 23 validation

'path' is defined but never used

Check failure on line 5 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 22 validation

'path' is defined but never used

Check failure on line 5 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 20 validation

'path' is defined but never used

Check failure on line 5 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 18 validation

'path' is defined but never used

import { KubeConfig } from './config.js';
import { Exec } from './exec.js';
import { getServers } from 'node:dns';

Check failure on line 9 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 23 validation

'getServers' is defined but never used

Check failure on line 9 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 22 validation

'getServers' is defined but never used

Check failure on line 9 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 20 validation

'getServers' is defined but never used

Check failure on line 9 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 18 validation

'getServers' is defined but never used

export class Cp {
public execInstance: Exec;
Expand All @@ -27,9 +29,9 @@
tgtPath: string,
): Promise<void> {
const tmpFile = tmp.fileSync();
const tmpFileName = tmpFile.name;

Check failure on line 32 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 23 validation

'tmpFileName' is assigned a value but never used

Check failure on line 32 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 22 validation

'tmpFileName' is assigned a value but never used

Check failure on line 32 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 20 validation

'tmpFileName' is assigned a value but never used

Check failure on line 32 in src/cp.ts

View workflow job for this annotation

GitHub Actions / Node 18 validation

'tmpFileName' is assigned a value but never used
const command = ['tar', 'zcf', '-', srcPath];
const writerStream = fs.createWriteStream(tmpFileName);
const writerStream = tar.extract(tgtPath);
const errStream = new WritableStreamBuffer();
this.execInstance.exec(
namespace,
Expand All @@ -44,10 +46,6 @@
if (errStream.size()) {
throw new Error(`Error from cpFromPod - details: \n ${errStream.getContentsAsString()}`);
}
await tar.x({
file: tmpFileName,
cwd: tgtPath,
});
},
);
}
Expand All @@ -66,16 +64,8 @@
srcPath: string,
tgtPath: string,
): Promise<void> {
const tmpFile = tmp.fileSync();
const tmpFileName = tmpFile.name;
const command = ['tar', 'xf', '-', '-C', tgtPath];
await tar.c(
{
file: tmpFile.name,
},
[srcPath],
);
const readStream = fs.createReadStream(tmpFileName);
const readStream = tar.pack(srcPath);
const errStream = new WritableStreamBuffer();
this.execInstance.exec(
namespace,
Expand Down
Loading