Documentation
¶
Index ¶
- Constants
- Variables
- func CacheFilename(url string) string
- func CopyToGuest(host hostActions, src, dest string) error
- func Download(host hostActions, r Request) (string, error)
- func DownloadToGuest(host hostActions, guest guestActions, r Request, filename string) error
- func SetDownloader(v string)
- func ValidateDownloader(v string) (string, error)
- type DownloadOptions
- type DownloadResult
- type FileDownloader
- type HTTPClient
- type HTTPStatusError
- type NetworkError
- type Request
- type ResumeError
- type ResumeInfo
- type SHA
- type SHAValidationError
Constants ¶
const ( // DownloaderNative uses Go's native HTTP client DownloaderNative = "native" // DownloaderCurl uses the curl command (honors .curlrc) DownloaderCurl = "curl" )
Variables ¶
var ( ErrNetworkConnection = errors.New("network connection error") ErrHTTPStatus = errors.New("HTTP error") ErrResumeFailed = errors.New("resume failed") ErrSHAValidation = errors.New("SHA validation failed") )
Sentinel errors for type checking
Functions ¶
func CacheFilename ¶ added in v0.7.0
CacheFilename returns the computed filename for the url.
func CopyToGuest ¶ added in v0.10.2
CopyToGuest copies a file or directory from the host to the guest VM using limactl copy.
func DownloadToGuest ¶ added in v0.7.0
DownloadToGuest downloads file at url and saves it in the destination.
In the implementation, the file is downloaded (and cached) on the host, then copied to the guest using limactl copy. filename must be an absolute path and a directory on the guest that does not require root access.
func SetDownloader ¶ added in v0.10.2
func SetDownloader(v string)
SetDownloader sets the downloader implementation based on the provided type. The value should be validated before calling this function.
func ValidateDownloader ¶ added in v0.10.2
ValidateDownloader validates the downloader value (case-insensitive). Returns the normalized value or an error if invalid.
Types ¶
type DownloadOptions ¶ added in v0.10.0
type DownloadOptions struct {
URL string
DestPath string
ExpectedETag string // for resume validation
ResumeFromByte int64 // byte offset to resume from
ShowProgress bool
}
DownloadOptions configures a download operation
type DownloadResult ¶ added in v0.10.0
type DownloadResult struct {
FinalURL string // After following redirects
ETag string // For future resume validation
TotalBytes int64
WasResumed bool
}
DownloadResult contains metadata about the completed download
type FileDownloader ¶ added in v0.10.2
FileDownloader is the interface for downloading files
type HTTPClient ¶ added in v0.10.0
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient encapsulates HTTP download operations
func NewHTTPClient ¶ added in v0.10.0
func NewHTTPClient() *HTTPClient
NewHTTPClient creates a configured HTTP client
func (*HTTPClient) Download ¶ added in v0.10.0
func (h *HTTPClient) Download(ctx context.Context, opts DownloadOptions) (*DownloadResult, error)
Download performs a file download with optional resume support
func (*HTTPClient) Fetch ¶ added in v0.10.0
Fetch downloads content from a URL and returns it as bytes (for small files like SHA checksums)
func (*HTTPClient) GetFinalURL ¶ added in v0.10.0
GetFinalURL follows redirects and returns the final URL
type HTTPStatusError ¶ added in v0.10.0
HTTPStatusError represents HTTP error responses
func (*HTTPStatusError) Error ¶ added in v0.10.0
func (e *HTTPStatusError) Error() string
func (*HTTPStatusError) Unwrap ¶ added in v0.10.0
func (e *HTTPStatusError) Unwrap() error
type NetworkError ¶ added in v0.10.0
NetworkError wraps network-related errors with user-friendly messages
func (*NetworkError) Error ¶ added in v0.10.0
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶ added in v0.10.0
func (e *NetworkError) Unwrap() error
type ResumeError ¶ added in v0.10.0
ResumeError indicates a failed resume attempt
func (*ResumeError) Error ¶ added in v0.10.0
func (e *ResumeError) Error() string
func (*ResumeError) Unwrap ¶ added in v0.10.0
func (e *ResumeError) Unwrap() error
type ResumeInfo ¶ added in v0.10.0
ResumeInfo stores metadata for resumable downloads
type SHA ¶ added in v0.6.0
type SHA struct {
Digest string // shasum
URL string // url to download the shasum file (if Digest is empty)
Size int // one of 256 or 512
}
SHA is the shasum of a file.
func (SHA) ValidateFile ¶ added in v0.8.1
ValidateFile validates the SHA of the file. The host parameter is kept for API compatibility but is not used.
type SHAValidationError ¶ added in v0.10.0
SHAValidationError indicates checksum mismatch
func (*SHAValidationError) Error ¶ added in v0.10.0
func (e *SHAValidationError) Error() string
func (*SHAValidationError) Unwrap ¶ added in v0.10.0
func (e *SHAValidationError) Unwrap() error