Documentation
¶
Index ¶
- func CleanDir(path string) (retErr error)
- func DecompressTarGzFromRemote(ctx context.Context, url string) iter.Seq2[*TarFile, error]
- func DownloadToLocalFile(ctx context.Context, url, filename string, perm os.FileMode) error
- func DownloadWithSHA256Verification(ctx context.Context, url, checksumURL, filename string, perm os.FileMode) error
- func InstallFile(filename string, r io.Reader, perm os.FileMode) error
- func IsDirEmpty(dir string) (bool, error)
- func IsExecutable(filePath string) bool
- func WriteFile(filename string, content []byte, perm os.FileMode) error
- type TarFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecompressTarGzFromRemote ¶
DecompressTarGzFromRemote returns an iterator that yields the files contained in a .tar.gz file located at the given URL.
func DownloadToLocalFile ¶
DownloadToLocalFile downloads content from giving URL to local file and sets the 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 DownloadWithSHA256Verification ¶
func DownloadWithSHA256Verification(ctx context.Context, url, checksumURL, filename string, perm os.FileMode) error
DownloadWithSHA256Verification downloads content from the given URL and verifies it against the SHA256 checksum fetched from checksumURL. The checksum file is expected to contain a hex-encoded SHA256 hash (optionally followed by whitespace and a filename, which is ignored).
NOTE: we assume the filename is trusted and cleaned without path traversal characters.
func InstallFile ¶
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 ¶
IsDirEmpty reports whether dir is empty or does not exist.