interface Container {
    copyFrom(srcPath: string, destDir: string): Promise<unknown>;
    copyTo(
        srcPath: string,
        destDir: string,
        filter?: TarCreateFilter,
    ): Promise<boolean>;
    execContainer(command: string | string[]): Promise<string>;
    hasDir(destPath: string): Promise<boolean>;
    hasFile(destPath: string, filters?: object): Promise<boolean>;
    listDir(destPath: string): Promise<any[] | TDirectoryData[]>;
    mkdir(destPath: string): Promise<string>;
}

Implemented by

Methods

  • Copy a file from a container

    It overwrites any existing file at the destination directory

    Parameters

    • srcPath: string

      the path to the file to copy

    • destDir: string

      the destination directory

    Returns Promise<unknown>

  • Copy a file into a container

    It overwrites any existing file inside the container at the destination directory

    Parameters

    • srcPath: string

      the path of the local file to copy

    • destDir: string

      the remote destination directory

    • Optionalfilter: TarCreateFilter

      the filter to pass to tar to keep or skip files or directories

    Returns Promise<boolean>

    a Promise that performs the copy operation

  • Invoke sh command within a container and return the console output as string

    Parameters

    • command: string | string[]

      sh commands as an array to be run within the containerName (e.g 'ls -la /opt/hgcapp')

    Returns Promise<string>

    console output as string

  • Check if a directory exists in the specified container

    Parameters

    • destPath: string

      the path to the directory inside the container

    Returns Promise<boolean>

  • Check if a file exists in the specified container

    Parameters

    • destPath: string

      the remote path to the file

    • Optionalfilters: object

      optional filters to apply to the tar stream

    Returns Promise<boolean>

  • List files and directories in a container

    It runs ls -la on the specified path and returns a list of object containing the entries. For example: [{ directory: false, owner: hedera, group: hedera, size: 121, modifiedAt: Jan 15 13:50 name: config.txt }]

    Parameters

    • destPath: string

      the remote path to the directory

    Returns Promise<any[] | TDirectoryData[]>

    a promise that returns array of directory entries, custom object