file

package
v4.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GZipImplEnvVarKey = "GZIP_IMPLEMENTATION"
	GZIP              = "GZip"
	PGZIP             = "PGZip"

	CompressionAlgorithmEnvVarKey = "WORKFLOW_COMPRESSION_ALGORITHM"
	GZipAlgorithm                 = "gzip"
	ZStdAlgorithm                 = "zstd"
	BrotliAlgorithm               = "brotli"

	// CompressionLevelEnvVarKey selects the compression level. Its range and
	// default are algorithm-specific: gzip 1-9 (default 6), zstd 1-4
	// (default 2), brotli 0-11 (default 6). Unset means each library's default.
	CompressionLevelEnvVarKey = "WORKFLOW_COMPRESSION_LEVEL"
)

Variables

This section is empty.

Functions

func CompressContent

func CompressContent(ctx context.Context, content []byte) []byte

CompressContent will compress the byte array using the algorithm selected by `CompressionAlgorithmEnvVarKey` (gzip by default). DecompressContent detects the algorithm from the content, so the variable only affects writes.

func CompressEncodeString

func CompressEncodeString(ctx context.Context, content string) string

CompressEncodeString will return the compressed string with base64 encoded

func DecodeDecompressString

func DecodeDecompressString(ctx context.Context, content string) (string, error)

DecodeDecompressString will return decode and decompress the

func DecompressContent

func DecompressContent(ctx context.Context, content []byte) ([]byte, error)

DecompressContent will return the uncompressed content, detecting the compression algorithm from the content. zstd and gzip are identified by their magic bytes; brotli streams have none, so anything else is treated as brotli (the only other algorithm we write).

func Exists

func Exists(path string) bool

Exists returns whether or not a path exists

func ExistsInTar

func ExistsInTar(sourcePath string, tarReader TarReader) bool

ExistsInTar return true if file or directory exists in tar

func GetGzipReader

func GetGzipReader(reader io.Reader) (io.ReadCloser, error)

GetGzipReader gets the GzipReader based on `GZipImplEnvVarKey` environment variable.

func IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory returns whether or not the given file is a directory

func WaitForCreate added in v4.1.0

func WaitForCreate(ctx context.Context, path string) error

WaitForCreate blocks until a file or directory exists at path, or ctx is cancelled. The parent directory of path MUST already exist; callers are responsible for creating it (e.g. with os.MkdirAll) before calling.

func WalkManifests

func WalkManifests(ctx context.Context, root string, fn func(path string, data []byte) error) error

WalkManifests is based on filepath.Walk but will only walk through Kubernetes manifests

func WatchFile added in v4.1.0

func WatchFile(ctx context.Context, path string, onChange func()) error

WatchFile invokes onChange whenever the file at path is created or written to. If the file already exists when the watcher starts, onChange is invoked once immediately. The parent directory of path MUST already exist.

Uses inotify when available; falls back to 2s polling if the kernel's inotify limits (fs.inotify.max_user_instances / max_user_watches) are exhausted.

Blocks until ctx is cancelled or an unrecoverable error occurs.

Types

type TarReader

type TarReader interface {
	Next() (*tar.Header, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL