Documentation
¶
Overview ¶
Package release provides helpers to download and verify binaries released on GitHub.
The downloader knows how to construct a release download URL, fetch the tarball, validate its checksum and extract the contained name to a destination path.
Index ¶
- type BinaryProvider
- type BinaryVersionChecker
- type BinaryVersionCheckerFactory
- type BinaryVersionComparator
- type GithubReleaseBinaryLocator
- type GithubReleaseCachePather
- type GithubReleaseChecksummer
- type GithubReleaseChecksummerFactory
- type GithubReleaseDownloader
- type GithubReleaseDownloaderOption
- func WithBinaryLocator(l GithubReleaseBinaryLocator) GithubReleaseDownloaderOption
- func WithCachePather(c GithubReleaseCachePather) GithubReleaseDownloaderOption
- func WithChecksummerFactory(c GithubReleaseChecksummerFactory) GithubReleaseDownloaderOption
- func WithLogger(l *log.Logger) GithubReleaseDownloaderOption
- func WithMaxDownloadSize(size int64) GithubReleaseDownloaderOption
- func WithOSGetter(c GithubReleaseOSGetter) GithubReleaseDownloaderOption
- func WithProgressor(p ioutil.Progressor) GithubReleaseDownloaderOption
- func WithURLGetter(c GithubReleaseURLGetter) GithubReleaseDownloaderOption
- func WithVersionCheckerFactory(f BinaryVersionCheckerFactory) GithubReleaseDownloaderOption
- type GithubReleaseOSGetter
- type GithubReleaseURLGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryProvider ¶
BinaryProvider is a small abstraction around downloading a specific name for a given version. Implementations should return the path of the downloaded name on success.
type BinaryVersionChecker ¶ added in v1.16.3
BinaryVersionChecker is a function that verifies the version of a downloaded binary matches the requested version. It takes a context and the path to the binary as input and returns an error if the version check fails (e.g., version mismatch or command execution error).
type BinaryVersionCheckerFactory ¶ added in v1.16.3
type BinaryVersionCheckerFactory func(requestedVersion string, os string, arch string) (BinaryVersionChecker, error)
BinaryVersionCheckerFactory is a factory function that creates a BinaryVersionChecker for a specific requested version and OS/architecture pair. This allows for customizable version checking logic that may vary based on the target platform or version.
func NewStaticCommandVersionCheckerFactory ¶ added in v1.16.3
func NewStaticCommandVersionCheckerFactory(args []string, outputParser func(stdout string) (string, error), comparator BinaryVersionComparator) BinaryVersionCheckerFactory
type BinaryVersionComparator ¶ added in v1.16.3
BinaryVersionComparator is a function that compares a requested version with the actual version extracted from a binary. It returns an error if the versions do not match according to the comparison logic (e.g., semver equality check).
func NewSemverEqualityComparator ¶ added in v1.16.3
func NewSemverEqualityComparator() BinaryVersionComparator
type GithubReleaseBinaryLocator ¶
type GithubReleaseBinaryLocator func(releaseDir string, name string, version string, os string, arch string) (string, error)
func NewDefaultBinaryLocator ¶
func NewDefaultBinaryLocator() GithubReleaseBinaryLocator
func NewOPStackBinaryLocator ¶
func NewOPStackBinaryLocator() GithubReleaseBinaryLocator
type GithubReleaseCachePather ¶
func NewHomeDirCachePather ¶
func NewHomeDirCachePather(namespace string) GithubReleaseCachePather
func NewStaticCachePather ¶ added in v1.16.3
func NewStaticCachePather(cacheDir string) GithubReleaseCachePather
type GithubReleaseChecksummer ¶
GithubReleaseChecksummer reads the downloaded archive data and validates its checksum. It should return an error if the checksum does not match.
func NewDefaultChecksummer ¶
func NewDefaultChecksummer(expectedChecksum string) GithubReleaseChecksummer
type GithubReleaseChecksummerFactory ¶
type GithubReleaseChecksummerFactory func(os string, arch string) (GithubReleaseChecksummer, error)
GithubReleaseChecksummerFactory returns a GithubReleaseChecksummer for a specific OS/architecture pair. This allows providing precomputed checksums for different release artifacts.
func NewStaticChecksummerFactory ¶
func NewStaticChecksummerFactory(checksums map[string]string) GithubReleaseChecksummerFactory
type GithubReleaseDownloader ¶
type GithubReleaseDownloader struct {
// contains filtered or unexported fields
}
func NewGithubReleaseDownloader ¶
func NewGithubReleaseDownloader(owner string, repo string, name string, opts ...GithubReleaseDownloaderOption) *GithubReleaseDownloader
type GithubReleaseDownloaderOption ¶
type GithubReleaseDownloaderOption func(*GithubReleaseDownloader)
func WithBinaryLocator ¶
func WithBinaryLocator(l GithubReleaseBinaryLocator) GithubReleaseDownloaderOption
func WithCachePather ¶
func WithCachePather(c GithubReleaseCachePather) GithubReleaseDownloaderOption
func WithChecksummerFactory ¶
func WithChecksummerFactory(c GithubReleaseChecksummerFactory) GithubReleaseDownloaderOption
func WithLogger ¶
func WithLogger(l *log.Logger) GithubReleaseDownloaderOption
func WithMaxDownloadSize ¶
func WithMaxDownloadSize(size int64) GithubReleaseDownloaderOption
func WithOSGetter ¶
func WithOSGetter(c GithubReleaseOSGetter) GithubReleaseDownloaderOption
func WithProgressor ¶
func WithProgressor(p ioutil.Progressor) GithubReleaseDownloaderOption
func WithURLGetter ¶
func WithURLGetter(c GithubReleaseURLGetter) GithubReleaseDownloaderOption
func WithVersionCheckerFactory ¶ added in v1.16.3
func WithVersionCheckerFactory(f BinaryVersionCheckerFactory) GithubReleaseDownloaderOption
type GithubReleaseOSGetter ¶
GithubReleaseOSGetter returns the OS and architecture string used to select the appropriate release artifact (e.g. "linux", "amd64"). The function may inspect the runtime or be overridden for testing.
func NewDefaultOSGetter ¶
func NewDefaultOSGetter() GithubReleaseOSGetter
type GithubReleaseURLGetter ¶
type GithubReleaseURLGetter func(owner string, repo string, name string, version string, os string, arch string) (string, error)
GithubReleaseURLGetter constructs the download URL for a given owner/repo and version for the provided os/arch pair.
func NewDefaultURLGetter ¶
func NewDefaultURLGetter() GithubReleaseURLGetter
func NewOPStackURLGetter ¶
func NewOPStackURLGetter() GithubReleaseURLGetter