...

Package tar

import "sigs.k8s.io/release-utils/tar"
Overview
Index

Overview ▾

func Compress

func Compress(tarFilePath, tarContentsPath string, excludes ...*regexp.Regexp) error

Compress the provided `tarContentsPath` into the `tarFilePath` while excluding the `exclude` regular expression patterns. This function will preserve path between `tarFilePath` and `tarContentsPath` directories inside the archive (see `CompressWithoutPreservingPath` as an alternative).

func CompressWithoutPreservingPath

func CompressWithoutPreservingPath(tarFilePath, tarContentsPath string, excludes ...*regexp.Regexp) error

Compress the provided `tarContentsPath` into the `tarFilePath` while excluding the `exclude` regular expression patterns. This function will not preserve path leading to the `tarContentsPath` directory in the archive.

func Extract

func Extract(tarFilePath, destinationPath string) error

Extract can be used to extract the provided `tarFilePath` into the `destinationPath`.

func ReadFileFromGzippedTar

func ReadFileFromGzippedTar(
    tarPath, filePath string,
) (res io.Reader, err error)

ReadFileFromGzippedTar opens a tarball and reads contents of a file inside.

func SanitizeArchivePath

func SanitizeArchivePath(d, t string) (v string, err error)

Sanitize archive file pathing from "G305: Zip Slip vulnerability" https://security.snyk.io/research/zip-slip-vulnerability