Documentation
¶
Index ¶
- Variables
- func DecompressTarGzFromRemote(ctx context.Context, url string) iter.Seq2[*TarFile, error]
- func DownloadToLocalFile(ctx context.Context, url string, filename string, perm os.FileMode) error
- func InstallFile(filename string, r io.Reader, perm os.FileMode) error
- func InstallFileWithLimitedSize(filename string, r io.Reader, perm os.FileMode, maxBytes int64) error
- func IsExecutable(filePath string) bool
- func WriteFile(filename string, content []byte, perm os.FileMode) error
- type TarFile
Constants ¶
This section is empty.
Variables ¶
var ErrFileTooLarge = errors.New("file exceeds maximum allowed size")
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 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 InstallFileWithLimitedSize ¶
func InstallFileWithLimitedSize(filename string, r io.Reader, perm os.FileMode, maxBytes int64) error
InstallFileWithLimitedSize streams content to local file with limited size and specified permissions. 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.