utilio

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDir

func CleanDir(path string) (retErr error)

CleanDir removes everything in a directory, but not the directory itself.

func InstallFile

func InstallFile(filename string, r io.Reader, perm os.FileMode) error

InstallFile writes the content from the provided reader to a local file with specified permissions. It limits the size of the content to 1 GiB and returns an error if the limit is exceeded. It ensures that the target directory exists and handles the file writing atomically.

NOTE: we assume the filename is trusted and cleaned without path traversal characters.

func IsDirEmpty

func IsDirEmpty(dir string) (bool, error)

IsDirEmpty reports whether dir is empty or does not exist.

func IsExecutable

func IsExecutable(filePath string) bool

func ProbeRemoteHTTPObject added in v0.1.20

func ProbeRemoteHTTPObject(ctx context.Context, source string) error

ProbeRemoteHTTPObject checks that an HTTP artifact object is reachable without downloading the full object. It first tries HEAD, then falls back to a ranged GET for servers that do not support or incorrectly reject HEAD.

func ProbeWritableDir added in v0.1.20

func ProbeWritableDir(dir string) error

ProbeWritableDir verifies that dir accepts file creation and removal without leaving durable state behind.

func UpdateSymlink(linkPath, targetPath string) error

UpdateSymlink atomically updates linkPath to point at targetPath.

func WriteFile

func WriteFile(filename string, content []byte, perm os.FileMode) error

WriteFile writes the provided content to a local file with specified permissions. It ensures that the target directory exists and handles the file writing atomically. The temp file is created in the same directory as the destination to preserve the correct SELinux label (avoiding the user_tmp_t label from /tmp).

NOTE: we assume the filename is trusted and cleaned without path traversal characters.

Types

type TarFile

type TarFile struct {
	Name string
	Size int64
	Body io.Reader
}

type TarFileSeq added in v0.1.21

type TarFileSeq = iter.Seq2[*TarFile, error]

func DecompressTarGz added in v0.1.21

func DecompressTarGz(body io.Reader) TarFileSeq

DecompressTarGz returns an iterator that yields the files contained in a gzip-compressed tar stream.

func DecompressTarGzFromRemote

func DecompressTarGzFromRemote(ctx context.Context, url string) TarFileSeq

DecompressTarGzFromRemote returns an iterator that yields the files contained in a .tar.gz file located at the given HTTP(S) URL.

Jump to

Keyboard shortcuts

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