Skip to content

Commit 93cd14b

Browse files
committed
k8 copyFrom cleanup
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent e661e29 commit 93cd14b

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/core/k8.mjs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ export class K8 {
343343
* @param {string} containerName
344344
* @param {string} destPath - path inside the container
345345
* @param {number} [timeout] - timeout in ms
346-
* @returns {Promise<{owner: string, size: number, modifiedAt: string, name: string, directory: boolean, group: string}>}
346+
* @returns {Promise<{owner: string, size: number, modifiedAt: string, name: string, directory: boolean, group: string}[]>}
347347
* array of directory entries, custom object
348348
*/
349349
async listDir (podName, containerName, destPath, timeout = 5000) {
@@ -567,13 +567,11 @@ export class K8 {
567567
const destPath = path.join(destDir, srcFile)
568568

569569
// download the tar file to a temp location
570-
// const tmpFile = `${this._tempFileFor(srcFile)}.tar`
571570
const tmpFile = this._tempFileFor(srcFile)
572571

573572
const self = this
574573
return new Promise((resolve, reject) => {
575574
const execInstance = new k8s.Exec(this.kubeConfig)
576-
// const command = ['tar', '-cf', '-', '-C', srcDir, srcFile]
577575
const command = ['cat', `${srcDir}/${srcFile}`]
578576
const outputFileStream = fs.createWriteStream(tmpFile)
579577
const outputPassthroughStream = new stream.PassThrough({ highWaterMark: 10 * 1024 * 1024 })
@@ -637,13 +635,8 @@ export class K8 {
637635

638636
try {
639637
fs.copyFileSync(tmpFile, destPath)
640-
// extract the downloaded file
641-
// tar.x({
642-
// file: tmpFile,
643-
// cwd: destDir
644-
// }).then(() => {
645-
// self._deleteTempFile(tmpFile)
646-
this.logger.debug(`tmpFile=${tmpFile}`)
638+
639+
self._deleteTempFile(tmpFile)
647640

648641
const stat = fs.statSync(destPath)
649642
let rejection
@@ -665,11 +658,6 @@ export class K8 {
665658
} else {
666659
return resolve(true)
667660
}
668-
// }).catch((err) => {
669-
// const errorMessage = `failed copying from ${podName}:${srcDir}/${srcFile} to ${destPath} to download file completely: ${destPath}${additionalErrorMessageDetail}`
670-
// this.logger.error(errorMessage, err)
671-
// return reject(new FullstackTestingError(errorMessage, err))
672-
// })
673661
} catch (e) {
674662
const errorMessage = `failed to complete copying from ${podName}:${srcDir}/${srcFile} to ${destPath} to extract file: ${destPath}`
675663
this.logger.error(errorMessage, e)

0 commit comments

Comments
 (0)