assets

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 28 Imported by: 0

README

1. get release information (latest or tag) update to v53 or v4 GraphQL api
2. filter: determine which asset to download (collect user/repo, os, arch, filterd_asset for analytics)
3. download asset, (timeout, resumable download, skip download if file exists, and use proxy if GITHUB_PROXY env is set)
4. validate checksum ???
5. process downloaded asset (call extractors or just copy), smart guess which one is the executable
6. verify installtion

(latest or tag) update to v53 or v4 GraphQL api

Documentation

Overview

download.go

download an asset after filtering

filter.go

filter assets from a release, determine which one is the one to download based on highest scoring

processor.go

process downloaded asset, maybe it is binary file(eg. jq-osx-amd64) or an archive(tar.gz, tar.xz, zip)

resolver.go

resolve target host info (OS, arch) for filtering the best asset to download

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeName

func SanitizeName(name, version string) string

SanitizeName removes irrelevant information from the file name in case it exists

Types

type Asset

type Asset struct {
	Name string
	// Some providers (like gitlab) have non-descriptive names for files,
	// so we're using this DisplayName as a helper to produce prettier
	// outputs for bin
	DisplayName        string
	URL                string
	Size               int64
	BrowserDownloadURL string
}

func (Asset) String

func (g Asset) String() string

type Filter

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

func InitFilter

func InitFilter(repoName string, name string, packagePath string, opts *FilterOpts) *Filter

func NewFilter

func NewFilter(opts *FilterOpts) *Filter

func (*Filter) FilterAssetContents

func (f *Filter) FilterAssetContents(repoName string, as []*Asset) (*FilteredAsset, error)

FilterAssetContents receives a slice of GL assets and tries to select the proper one and ask the user to manually select one in case it can't determine it

func (*Filter) FilterAssets

func (f *Filter) FilterAssets(repoName string, as []*Asset) (*FilteredAsset, error)

FilterAssets receives a slice of GL assets and tries to select the proper one and ask the user to manually select one in case it can't determine it

func (*Filter) ProcessURL

func (f *Filter) ProcessURL(gf *FilteredAsset) (*finalFile, error)

ProcessURL processes a FilteredAsset by uncompressing/unarchiving the URL of the asset.

type FilterOpts

type FilterOpts struct {
	SkipScoring   bool
	SkipPathCheck bool

	// If target file is in a package format (tar, zip,etc) use this
	// variable to filter the resulting outputs. This is very useful
	// so we don't prompt the user to pick the file again on updates
	PackagePath string
}

type FilteredAsset

type FilteredAsset struct {
	RepoName           string
	Name               string
	DisplayName        string
	URL                string // API URL: https://api.github.com/repos/BurntSushi/ripgrep/releases/assets/38486907
	BrowserDownloadURL string // BrowserDownloadURL: https://github.com/junegunn/fzf/releases/download/0.42.0/fzf-0.42.0-darwin_amd64.zip

	Size         int64
	ContentMd5   string
	ExtraHeaders map[string]string
	// contains filtered or unexported fields
}

TODO: use BrowserDownloadURL to download not API URL see ReleaseAsset struct in go-github/github/repo_releases.go

func (FilteredAsset) String

func (g FilteredAsset) String() string

Jump to

Keyboard shortcuts

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