Documentation
¶
Overview ¶
Package toolchain resolves, verifies, and caches Pawn compilers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrOffline is returned when a resolution requires a download and // none is available (no Downloader configured, or Offline was set). ErrOffline = errors.New("toolchain: no network downloader configured (offline)") // ErrNotFound is returned when Resolve cannot locate a compiler by any // configured mode. ErrNotFound = errors.New("toolchain: no compiler could be resolved") // ErrChecksumMismatch is returned when a downloaded or locally // configured artifact's checksum does not match the expected value. ErrChecksumMismatch = errors.New("toolchain: checksum mismatch") // ErrInvalidCoordinate is returned for an unsupported vendor or unsafe // version string. ErrInvalidCoordinate = errors.New("toolchain: invalid toolchain coordinate") // ErrDownloadURLRequired is returned when a download is needed but the // caller did not provide an artifact URL. ErrDownloadURLRequired = errors.New("toolchain: download URL required") )
var ErrArchiveTooLarge = errors.New("toolchain: archive exceeds extraction limits")
ErrArchiveTooLarge is returned when an archive exceeds the file-count or total-byte extraction limits.
var ErrArchiveTraversal = errors.New("toolchain: archive entry escapes extraction root")
ErrArchiveTraversal is returned when a zip entry's name would extract outside the destination directory.
Functions ¶
func DefaultCacheDir ¶
DefaultCacheDir returns the user cache directory for Pawn toolchains.
Types ¶
type CacheFS ¶
type CacheFS interface {
fsx.FS
MkdirAll(path string) error
RemoveAll(path string) error
Rename(oldPath, newPath string) error
WriteFile(path string, content []byte) error // WriteFile stores content without making it executable.
}
CacheFS adds the writes needed by the toolchain cache.
type Clock ¶
type Clock interface {
Now() int64 // Unix seconds
}
Clock provides Unix time for cache operations.
type Downloader ¶
Downloader fetches a remote artifact by URL.
type HTTPDownloader ¶
HTTPDownloader fetches HTTPS artifacts with an injected client.
func (HTTPDownloader) Download ¶
func (d HTTPDownloader) Download(ctx context.Context, rawURL string) (io.ReadCloser, error)
type Info ¶
type Info struct {
Vendor Vendor
Version string
Path string // absolute path to the compiler binary
Checksum string // "sha256:<hex>" of the binary at Path
ArtifactChecksum string // checksum of the downloaded artifact
}
Info describes a resolved compiler toolchain.
type NoNetworkDownloader ¶
type NoNetworkDownloader struct{}
NoNetworkDownloader rejects every download with ErrOffline.
func (NoNetworkDownloader) Download ¶
func (NoNetworkDownloader) Download(context.Context, string) (io.ReadCloser, error)
type ResolveOptions ¶
type ResolveOptions struct {
// LocalPath takes precedence and never uses the network.
LocalPath string
// Vendor and Version identify a pinned toolchain.
Vendor Vendor
Version string
// DownloadURL is the HTTPS artifact URL used when the requested compiler
// is not cached. It is ignored for local paths and cache hits.
DownloadURL string
// ExpectedChecksum verifies the local or downloaded artifact when set.
ExpectedChecksum string
// Offline restricts Resolve to local and cached compilers.
Offline bool
}
ResolveOptions configures one Resolve call.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves, caches, and lists compiler toolchains.
func NewResolver ¶
func NewResolver(fsys CacheFS, cacheDir string, downloader Downloader, clock Clock) *Resolver
NewResolver builds a Resolver. A nil downloader disables network access.
type SystemClock ¶
type SystemClock struct{}
SystemClock calls the real wall clock.
func (SystemClock) Now ¶
func (SystemClock) Now() int64