Documentation
¶
Index ¶
- Variables
- func CleanDir(path string) (retErr error)
- 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 FileExists(path string) bool
- 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 CleanDir ¶ added in v0.0.17
CleanDir removes everything in a directory, but not the directory itself.
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 FileExists ¶ added in v0.1.0
FileExists checks if a file exists.
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. The temp file is created in the same directory as the destination to preserve the correct SELinux label.
NOTE: we assume the filename is trusted and cleaned without path traversal characters.
func IsExecutable ¶
func WriteFile ¶
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.
NOTE: we assume the filename is trusted and cleaned without path traversal characters.