Documentation
¶
Index ¶
- Constants
- func CompressContent(ctx context.Context, content []byte) []byte
- func CompressEncodeString(ctx context.Context, content string) string
- func DecodeDecompressString(ctx context.Context, content string) (string, error)
- func DecompressContent(ctx context.Context, content []byte) ([]byte, error)
- func Exists(path string) bool
- func ExistsInTar(sourcePath string, tarReader TarReader) bool
- func GetGzipReader(reader io.Reader) (io.ReadCloser, error)
- func IsDirectory(path string) (bool, error)
- func WaitForCreate(ctx context.Context, path string) error
- func WalkManifests(ctx context.Context, root string, fn func(path string, data []byte) error) error
- func WatchFile(ctx context.Context, path string, onChange func()) error
- type TarReader
Constants ¶
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 ¶
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 ¶
CompressEncodeString will return the compressed string with base64 encoded
func DecodeDecompressString ¶
DecodeDecompressString will return decode and decompress the
func DecompressContent ¶
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 ExistsInTar ¶
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 ¶
IsDirectory returns whether or not the given file is a directory
func WaitForCreate ¶ added in v4.1.0
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 ¶
WalkManifests is based on filepath.Walk but will only walk through Kubernetes manifests
func WatchFile ¶ added in v4.1.0
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.