install

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = errors.New("no github token")

Functions

func CacheFilePath

func CacheFilePath(cacheDir, url string) string

func Cast

func Cast[T any](value any) (T, error)

func Download

func Download(url string, out io.Writer, getbar func(size int64) *pb.ProgressBar, opts Options) error

func Get

func Get(url string, disableSSL bool) (*http.Response, error)

func GetWithOptions

func GetWithOptions(url string, opts Options) (*http.Response, error)

func IsGitHubURL

func IsGitHubURL(s string) bool

func IsLocalFile

func IsLocalFile(s string) bool

func IsURL

func IsURL(s string) bool

func NormalizeRepoTarget

func NormalizeRepoTarget(target string) (string, error)

func SelectExtractorAs

func SelectExtractorAs[T any](s *Service, url, tool string, opts *Options) (T, error)

func SetVerbose

func SetVerbose(enabled bool, writer io.Writer)

func VerboseEnabledForTest

func VerboseEnabledForTest() bool

Types

type Archive

type Archive interface {
	Next() (File, error)
	ReadAll() ([]byte, error)
}

func NewTarArchive

func NewTarArchive(data []byte, decompress DecompFn) (Archive, error)

func NewZipArchive

func NewZipArchive(data []byte, d DecompFn) (Archive, error)

type ArchiveExtractor

type ArchiveExtractor struct {
	File       Chooser
	Ar         ArchiveFn
	Decompress DecompFn
}

func NewArchiveExtractor

func NewArchiveExtractor(file Chooser, ar ArchiveFn, decompress DecompFn) *ArchiveExtractor

func (*ArchiveExtractor) Extract

func (a *ArchiveExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

type ArchiveFn

type ArchiveFn func(data []byte, decomp DecompFn) (Archive, error)

type BinaryChooser

type BinaryChooser struct {
	Tool string
}

func NewBinaryChooser

func NewBinaryChooser(tool string) *BinaryChooser

func (*BinaryChooser) Choose

func (b *BinaryChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

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)
}

type DecompFn

type DecompFn func(r io.Reader) (io.Reader, error)

type Detector

type Detector interface {
	Detect(assets []string) (string, []string, error)
}

type DirectAssetFinder

type DirectAssetFinder struct {
	URL string
}

func (*DirectAssetFinder) Find

func (f *DirectAssetFinder) Find() ([]string, error)

type ExtractedFile

type ExtractedFile struct {
	Name        string
	ArchiveName string

	Extract func(to string) error
	Dir     bool
	// contains filtered or unexported fields
}

func (ExtractedFile) Mode

func (e ExtractedFile) Mode() fs.FileMode

func (ExtractedFile) String

func (e ExtractedFile) String() string

type Extractor

type Extractor interface {
	Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
}

func NewExtractor

func NewExtractor(filename string, tool string, chooser Chooser) Extractor

type File

type File struct {
	Name     string
	LinkName string
	Mode     fs.FileMode
	Type     FileType
}

func (File) Dir

func (f File) Dir() bool

type FileType

type FileType byte
const (
	TypeNormal FileType = iota
	TypeDir
	TypeLink
	TypeSymlink
	TypeOther
)

type Finder

type Finder interface {
	Find() ([]string, error)
}

type GlobChooser

type GlobChooser struct {
	// contains filtered or unexported fields
}

func NewGlobChooser

func NewGlobChooser(gl string) (*GlobChooser, error)

func (*GlobChooser) Choose

func (g *GlobChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*GlobChooser) String

func (g *GlobChooser) String() string

type HTTPGetterFunc

type HTTPGetterFunc func(url string) (*http.Response, error)

func NewHTTPGetter

func NewHTTPGetter(opts Options) HTTPGetterFunc

func (HTTPGetterFunc) Get

func (f HTTPGetterFunc) Get(url string) (*http.Response, error)

type InstallRunner

type InstallRunner struct {
	Service       *Service
	InstalledLoad func() (map[string]string, map[string]string, error)
	Prompt        PromptFunc
	Stdout        io.Writer
	Stderr        io.Writer
}

func NewRunner

func NewRunner(service *Service) *InstallRunner

func (*InstallRunner) Run

func (r *InstallRunner) Run(target string, opts Options) (RunResult, error)

type LiteralFileChooser

type LiteralFileChooser struct {
	File string
}

func (*LiteralFileChooser) Choose

func (l *LiteralFileChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*LiteralFileChooser) String

func (l *LiteralFileChooser) String() string

type Options

type Options struct {
	Tag          string
	Prerelease   bool
	Name         string
	Verbose      bool
	Source       bool
	Output       string
	CacheDir     string
	ProxyURL     string
	System       string
	ExtractFile  string
	All          bool
	Quiet        bool
	DownloadOnly bool
	UpgradeOnly  bool
	Asset        []string
	Hash         bool
	Verify       string
	DisableSSL   bool
}

type PromptFunc

type PromptFunc func(choices []string) (int, error)

type RateLimit

type RateLimit struct {
	Limit     int   `json:"limit"`
	Remaining int   `json:"remaining"`
	Reset     int64 `json:"reset"`
}

func GetRateLimit

func GetRateLimit(opts Options) (RateLimit, error)

func (RateLimit) ResetTime

func (r RateLimit) ResetTime() time.Time

type RateLimitJSON

type RateLimitJSON struct {
	Resources map[string]RateLimit `json:"resources"`
}

type RunResult

type RunResult struct {
	URL            string
	Tool           string
	Asset          string
	ExtractedFiles []string
}

type Runner

type Runner interface {
	Run(target string, opts Options) (RunResult, error)
}

type Service

type Service struct {
	BinaryModTime       func(tool, output string) time.Time
	GitHubGetter        sourcegithub.HTTPGetter
	GitHubGetterFactory func(opts Options) sourcegithub.HTTPGetter

	AllDetectorFactory    func() Detector
	SystemDetectorFactory func(goos, goarch string) (Detector, error)
	AssetDetectorFactory  func(asset string, anti bool) Detector
	DetectorChainFactory  func(detectors []Detector, system Detector) Detector

	Sha256VerifierFactory      func(expected string) (Verifier, error)
	Sha256AssetVerifierFactory func(assetURL string, opts Options) Verifier
	Sha256PrinterFactory       func() Verifier
	NoVerifierFactory          func() Verifier

	DownloadOnlyExtractorFactory func(name string) any
	GlobChooserFactory           func(pattern string) (any, error)
	BinaryChooserFactory         func(tool string) any
	ExtractorFactory             func(filename, tool string, chooser any) any
}

func NewDefaultService

func NewDefaultService(githubGetter sourcegithub.HTTPGetter, binaryModTime func(tool, output string) time.Time) *Service

func NewService

func NewService() *Service

func (*Service) SelectDetector

func (s *Service) SelectDetector(opts *Options) (Detector, error)

func (*Service) SelectExtractor

func (s *Service) SelectExtractor(url, tool string, opts *Options) (any, error)

func (*Service) SelectFinder

func (s *Service) SelectFinder(target string, opts *Options) (Finder, string, error)

func (*Service) SelectVerifier

func (s *Service) SelectVerifier(sumAsset string, opts *Options) (Verifier, error)

type SingleFileExtractor

type SingleFileExtractor struct {
	Rename     string
	Name       string
	Decompress func(r io.Reader) (io.Reader, error)
}

func NewDownloadOnlyExtractor

func NewDownloadOnlyExtractor(name string) *SingleFileExtractor

func (*SingleFileExtractor) Extract

func (s *SingleFileExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

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 TargetKind

type TargetKind string
const (
	TargetUnknown   TargetKind = "unknown"
	TargetRepo      TargetKind = "repo"
	TargetGitHubURL TargetKind = "github_url"
	TargetDirectURL TargetKind = "direct_url"
	TargetLocalFile TargetKind = "local_file"
)

func DetectTargetKind

func DetectTargetKind(target string) TargetKind

type Verifier

type Verifier interface {
	Verify(b []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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL