|
| 1 | +/** |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + */ |
| 4 | + |
| 5 | +import {type TarCreateFilter} from '../../types/aliases.js'; |
| 6 | +import {type TDirectoryData} from './t_directory_data.js'; |
| 7 | + |
| 8 | +export interface Container { |
| 9 | + /** |
| 10 | + * Copy a file from a container |
| 11 | + * |
| 12 | + * It overwrites any existing file at the destination directory |
| 13 | + * @param srcPath - the path to the file to copy |
| 14 | + * @param destDir - the destination directory |
| 15 | + */ |
| 16 | + copyFrom(srcPath: string, destDir: string): Promise<unknown>; |
| 17 | + |
| 18 | + /** |
| 19 | + * Copy a file into a container |
| 20 | + * |
| 21 | + * It overwrites any existing file inside the container at the destination directory |
| 22 | + * @param srcPath - the path of the local file to copy |
| 23 | + * @param destDir - the remote destination directory |
| 24 | + * @param [filter] - the filter to pass to tar to keep or skip files or directories |
| 25 | + * @returns a Promise that performs the copy operation |
| 26 | + */ |
| 27 | + copyTo(srcPath: string, destDir: string, filter: TarCreateFilter | undefined): Promise<boolean>; |
| 28 | + |
| 29 | + /** |
| 30 | + * Invoke sh command within a container and return the console output as string |
| 31 | + * @param command - sh commands as an array to be run within the containerName (e.g 'ls -la /opt/hgcapp') |
| 32 | + * @returns console output as string |
| 33 | + */ |
| 34 | + execContainer(command: string | string[]): Promise<string>; |
| 35 | + |
| 36 | + /** |
| 37 | + * Check if a directory exists in the specified container |
| 38 | + * @param destPath - the path to the directory inside the container |
| 39 | + */ |
| 40 | + hasDir(destPath: string): Promise<boolean>; |
| 41 | + |
| 42 | + /** |
| 43 | + * Check if a file exists in the specified container |
| 44 | + * @param destPath - the remote path to the file |
| 45 | + * @param [filters] - optional filters to apply to the tar stream |
| 46 | + */ |
| 47 | + hasFile(destPath: string, filters: object): Promise<boolean>; |
| 48 | + |
| 49 | + /** |
| 50 | + * List files and directories in a container |
| 51 | + * |
| 52 | + * It runs ls -la on the specified path and returns a list of object containing the entries. |
| 53 | + * For example: |
| 54 | + * [{ |
| 55 | + * directory: false, |
| 56 | + * owner: hedera, |
| 57 | + * group: hedera, |
| 58 | + * size: 121, |
| 59 | + * modifiedAt: Jan 15 13:50 |
| 60 | + * name: config.txt |
| 61 | + * }] |
| 62 | + * @param destPath - the remote path to the directory |
| 63 | + * @returns a promise that returns array of directory entries, custom object |
| 64 | + */ |
| 65 | + listDir(destPath: string): Promise<any[] | TDirectoryData[]>; |
| 66 | + |
| 67 | + /** |
| 68 | + * Make a directory in the specified container |
| 69 | + * @param destPath - the remote path to the directory |
| 70 | + */ |
| 71 | + mkdir(destPath: string): Promise<string>; |
| 72 | +} |
0 commit comments