Documentation
¶
Index ¶
- Variables
- func Cut(s, sep string) (before, after string, found bool)
- func Download(url string, out io.Writer, getbar func(size int64) *pb.ProgressBar) error
- func DownloadConfigRepositories(cfg *config.Config) error
- func Get(url string) (*http.Response, error)
- func IsDirectory(path string) bool
- func IsGithubUrl(s string) bool
- func IsLocalFile(s string) bool
- func IsUrl(s string) bool
- func ListAvailable(target string, opts options.Flags) ([]string, error)
- func RefreshInstalledPackage(pkg installed.Package) (installed.Package, error)
- func Run(target string, opts options.Flags) error
- func SetAuthHeader(req *http.Request) *http.Request
- func SetDisableSSL(disable bool)
- type AllDetector
- type Arch
- type Archive
- type ArchiveExtractor
- type ArchiveFn
- type BinaryChooser
- type Chooser
- type DecompFn
- type Detector
- type DetectorChain
- type DirectAssetFinder
- type ExtractedFile
- type Extractor
- type File
- type FileType
- type Finder
- type GithubAssetFinder
- type GithubError
- type GithubRelease
- type GithubSourceFinder
- type GlobChooser
- type LiteralFileChooser
- type NoVerifier
- type OS
- type RateLimit
- type RateLimitJson
- type Sha256AssetVerifier
- type Sha256Error
- type Sha256Printer
- type Sha256Verifier
- type SingleAssetDetector
- type SingleFileExtractor
- type SystemDetector
- type TarArchive
- type Verifier
- type ZipArchive
Constants ¶
This section is empty.
Variables ¶
var ( OSDarwin = OS{ // contains filtered or unexported fields } OSWindows = OS{ // contains filtered or unexported fields } OSLinux = OS{ // contains filtered or unexported fields } OSNetBSD = OS{ // contains filtered or unexported fields } OSFreeBSD = OS{ // contains filtered or unexported fields } OSOpenBSD = OS{ // contains filtered or unexported fields } OSAndroid = OS{ // contains filtered or unexported fields } OSIllumos = OS{ // contains filtered or unexported fields } OSSolaris = OS{ // contains filtered or unexported fields } OSPlan9 = OS{ // contains filtered or unexported fields } )
var ( ArchAMD64 = Arch{ // contains filtered or unexported fields } ArchI386 = Arch{ // contains filtered or unexported fields } ArchArm = Arch{ // contains filtered or unexported fields } ArchArm64 = Arch{ // contains filtered or unexported fields } ArchRiscv64 = Arch{ // contains filtered or unexported fields } )
var ErrNoToken = errors.New("no github token")
var ErrNoUpgrade = errors.New("requested release is not more recent than current version")
Functions ¶
func Download ¶
Download the file at 'url' and write the http response body to 'out'. The 'getbar' function allows the caller to construct a progress bar given the size of the file being downloaded, and the download will write to the returned progress bar.
func IsDirectory ¶
IsDirectory returns true if the file at path is a directory.
func IsGithubUrl ¶
IsGithubUrl returns true if s is a URL with github.com as the host.
func IsLocalFile ¶
func RefreshInstalledPackage ¶
func SetDisableSSL ¶
func SetDisableSSL(disable bool)
Types ¶
type AllDetector ¶
type AllDetector struct{}
AllDetector matches every asset. If there is only one asset, it is returned as a direct match. If there are multiple assets they are all returned as candidates.
type Arch ¶
type Arch struct {
// contains filtered or unexported fields
}
An Arch represents a system architecture, such as amd64, i386, arm or others.
type ArchiveExtractor ¶
func (*ArchiveExtractor) Extract ¶
func (a *ArchiveExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
type BinaryChooser ¶
type BinaryChooser struct {
Tool string
}
A BinaryChooser selects executable files. If the executable file has the name 'Tool' it is considered a direct match. If the file is only executable, it is a possible match.
func (*BinaryChooser) String ¶
func (b *BinaryChooser) String() string
type Chooser ¶
type Chooser interface {
Choose(name string, dir bool, mode fs.FileMode) (direct bool, possible bool)
}
A Chooser selects a file. It may list the file as a direct match (should be immediately extracted if found), or a possible match (only extract if it is the only match, or if the user manually requests it).
type Detector ¶
type Detector interface {
// Detect takes a list of possible assets and returns a direct match. If a
// single direct match is not found, it returns a list of candidates and an
// error explaining what happened.
Detect(assets []string) (string, []string, error)
}
A Detector selects an asset from a list of possibilities.
type DetectorChain ¶
type DetectorChain struct {
// contains filtered or unexported fields
}
type DirectAssetFinder ¶
type DirectAssetFinder struct {
URL string
}
A DirectAssetFinder returns the embedded URL directly as the only asset.
func (*DirectAssetFinder) Find ¶
func (f *DirectAssetFinder) Find() ([]string, error)
type ExtractedFile ¶
type ExtractedFile struct {
Name string // name to extract to
ArchiveName string // name in archive
Extract func(to string) error
Dir bool
// contains filtered or unexported fields
}
An ExtractedFile contains the data, name, and permissions of a file in the archive.
func (ExtractedFile) Mode ¶
func (e ExtractedFile) Mode() fs.FileMode
Mode returns the filemode of the extracted file.
func (ExtractedFile) String ¶
func (e ExtractedFile) String() string
String returns the archive name of this extracted file
type Extractor ¶
type Extractor interface {
Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
}
An Extractor reads in some archive data and extracts a particular file from it. If there are multiple candidates it returns a list and an error explaining what happened.
func NewExtractor ¶
NewExtractor constructs an extractor for the given archive file using the given chooser. It will construct extractors for files ending in '.tar.gz', '.tar.bz2', '.tar', '.zip'. After these matches, if the file ends with '.gz', '.bz2' it will be decompressed and copied. Other files will simply be copied without any decompression or extraction.
type GithubAssetFinder ¶
type GithubAssetFinder struct {
Repo string
Tag string
Prerelease bool
MinTime time.Time // release must be after MinTime to be found
Digests map[string]string
ReleaseTag string
}
A GithubAssetFinder finds assets for the given Repo at the given tag. Tags must be given as 'tag/<tag>'. Use 'latest' to get the latest release.
func (*GithubAssetFinder) Find ¶
func (f *GithubAssetFinder) Find() ([]string, error)
func (*GithubAssetFinder) FindMatch ¶
func (f *GithubAssetFinder) FindMatch() ([]string, error)
type GithubError ¶
func (*GithubError) Error ¶
func (ge *GithubError) Error() string
type GithubRelease ¶
type GithubRelease struct {
Assets []struct {
DownloadURL string `json:"browser_download_url"`
Digest string `json:"digest"`
} `json:"assets"`
Prerelease bool `json:"prerelease"`
Tag string `json:"tag_name"`
CreatedAt time.Time `json:"created_at"`
}
A GithubRelease matches the Assets portion of Github's release API json.
type GithubSourceFinder ¶
func (*GithubSourceFinder) Find ¶
func (f *GithubSourceFinder) Find() ([]string, error)
type GlobChooser ¶
type GlobChooser struct {
// contains filtered or unexported fields
}
func NewGlobChooser ¶
func NewGlobChooser(gl string) (*GlobChooser, error)
func (*GlobChooser) String ¶
func (gc *GlobChooser) String() string
type LiteralFileChooser ¶
type LiteralFileChooser struct {
File string
}
LiteralFileChooser selects files with the name 'File'.
func (*LiteralFileChooser) String ¶
func (lf *LiteralFileChooser) String() string
type NoVerifier ¶
type NoVerifier struct{}
func (*NoVerifier) Verify ¶
func (n *NoVerifier) Verify(b []byte) error
type OS ¶
type OS struct {
// contains filtered or unexported fields
}
An OS represents a target operating system.
type RateLimit ¶
func GetRateLimit ¶
type RateLimitJson ¶
type Sha256AssetVerifier ¶
type Sha256AssetVerifier struct {
AssetURL string
}
func (*Sha256AssetVerifier) Verify ¶
func (s256 *Sha256AssetVerifier) Verify(b []byte) error
type Sha256Error ¶
func (*Sha256Error) Error ¶
func (e *Sha256Error) Error() string
type Sha256Printer ¶
type Sha256Printer struct{}
func (*Sha256Printer) Verify ¶
func (s256 *Sha256Printer) Verify(b []byte) error
type Sha256Verifier ¶
type Sha256Verifier struct {
Expected []byte
}
func NewSha256Verifier ¶
func NewSha256Verifier(expectedHex string) (*Sha256Verifier, error)
func (*Sha256Verifier) Verify ¶
func (s256 *Sha256Verifier) Verify(b []byte) error
type SingleAssetDetector ¶
SingleAssetDetector finds a single named asset. If Anti is true it finds all assets that don't contain Asset.
type SingleFileExtractor ¶
type SingleFileExtractor struct {
Rename string
Name string
Decompress func(r io.Reader) (io.Reader, error)
}
SingleFileExtractor extracts files called 'Name' after decompressing the file with 'Decompress'.
func (*SingleFileExtractor) Extract ¶
func (sf *SingleFileExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
type SystemDetector ¶
A SystemDetector matches a particular OS/Arch system pair.
func NewSystemDetector ¶
func NewSystemDetector(sos, sarch string) (*SystemDetector, error)
NewSystemDetector returns a new detector for the given OS/Arch as given by Go OS/Arch names.
func (*SystemDetector) Detect ¶
func (d *SystemDetector) Detect(assets []string) (string, []string, error)
Detect extracts the assets that match this detector's OS/Arch pair. If one direct OS/Arch match is found, it is returned. If multiple OS/Arch matches are found they are returned as candidates. If multiple assets that only match the OS are found, and no full OS/Arch matches are found, the OS matches are returned as candidates. Otherwise all assets are returned as candidates.
type TarArchive ¶
type TarArchive struct {
// contains filtered or unexported fields
}
func (*TarArchive) Next ¶
func (t *TarArchive) Next() (File, error)
func (*TarArchive) ReadAll ¶
func (t *TarArchive) ReadAll() ([]byte, error)
type ZipArchive ¶
type ZipArchive struct {
// contains filtered or unexported fields
}
func (*ZipArchive) Next ¶
func (z *ZipArchive) Next() (File, error)
func (*ZipArchive) ReadAll ¶
func (z *ZipArchive) ReadAll() ([]byte, error)