Documentation
¶
Overview ¶
Package toolchain resolves, verifies, and caches Pawn compilers.
Index ¶
- Variables
- func DefaultCacheDir() (string, error)
- func FindCompiler(lookup PathLookup, candidates ...string) (string, error)
- type CacheFS
- type Clock
- type CompilerArchive
- type CompilerArtifact
- type CompilerExecutable
- type CompilerSource
- type Coordinate
- type Downloader
- type HTTPDownloader
- type Index
- type Info
- type NoNetworkDownloader
- type OSCacheFS
- type OSPathLookup
- type PathLookup
- type Platform
- type ResolveOptions
- type Resolver
- type SystemClock
- type Vendor
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.
func FindCompiler ¶ added in v0.3.9
func FindCompiler(lookup PathLookup, candidates ...string) (string, error)
FindCompiler returns the first compiler found in candidate order.
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 CompilerArchive ¶ added in v0.4.0
type CompilerArtifact ¶ added in v0.4.0
type CompilerArtifact struct {
Vendor Vendor `json:"vendor"`
Version string `json:"version"`
Profiles []string `json:"profiles"`
Target string `json:"target"`
Source CompilerSource `json:"source"`
Archive CompilerArchive `json:"archive"`
Executable CompilerExecutable `json:"executable"`
}
CompilerArtifact identifies one compiler archive.
func (CompilerArtifact) ResolveOptions ¶ added in v0.5.0
func (artifact CompilerArtifact) ResolveOptions() ResolveOptions
ResolveOptions returns the verified download settings for the artifact.
type CompilerExecutable ¶ added in v0.4.0
type CompilerSource ¶ added in v0.4.0
type Coordinate ¶ added in v0.3.11
Coordinate identifies one pinned compiler.
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 Index ¶ added in v0.4.0
type Index struct {
SchemaVersion int `json:"schemaVersion"`
ID string `json:"id"`
GeneratedAt string `json:"generatedAt"`
Artifacts []CompilerArtifact `json:"artifacts"`
}
Index contains reviewed compiler artifacts.
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 OSPathLookup ¶ added in v0.3.9
type OSPathLookup struct{}
OSPathLookup searches the current process PATH.
type PathLookup ¶ added in v0.3.9
PathLookup finds executables using the host's command search rules.
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
// ExpectedSize is the exact downloaded artifact size when non-zero.
ExpectedSize int64
// ArchiveFormat and ExecutablePath describe a reviewed artifact layout.
ArchiveFormat string
ExecutablePath string
// ExpectedExecutableChecksum verifies the extracted compiler.
ExpectedExecutableChecksum 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