Documentation ¶
Index ¶
- Variables
- func CopyFile(src, dst string, permissions int) (int64, error)
- func Download(tool *Tool, arch, opSystem, version string) (string, error)
- func GetBinaryName(tool *Tool, os, arch, version string) (string, error)
- func GetClientArch() (arch, os string)
- func GetDownloadURL(tool Tool, arch, opSystem, version string) (string, error)
- func InitUserDir() (string, error)
- func ListToolsTable(tools Tools)
- func LocalBinary(name, subdir string) (string, error)
- func PostInstallationMessage(localToolsStore ToolLocal) ([]byte, error)
- func PrintPostInstallMessage(t Tool) error
- func Untar(r io.Reader, target string, gzip bool) error
- func Unzip(r io.ReaderAt, size int64, target string) error
- type GithubAPIReleasesResponse
- type Tool
- type ToolLocal
- type Tools
Constants ¶
This section is empty.
Variables ¶
var Cmd = &Z.Cmd{ Name: `get`, Summary: `install executables and applications on the host system [requires internet]`, Description: ` The *get* command downloads a tools or applications from that providers releases or downloads page. Typically, tools are downloaded as a binary for fast and efficient access on the host platform. `, Other: []Z.Section{ { Title: "Examples", Body: ` ds get - list all available tools ds get arkade - download the Arkade binary`, }, }, Commands: []*Z.Cmd{ help.Cmd, }, Call: func(_ *Z.Cmd, args ...string) error { tools := MakeTools() arch, opSystem := GetClientArch() sort.Sort(tools) if len(args) == 0 { ListToolsTable(tools) return nil } tool := args[0] log.Printf("Looking up version for %q\n", tool) t, err := getTool(tool, tools) if err != nil { return err } version := t.Version if version == "" { version = "latest" } _, err = Download(&t, arch, opSystem, version) if err != nil { return err } err = PrintPostInstallMessage(t) if err != nil { return err } return nil }, }
Functions ¶
func GetBinaryName ¶
GetBinaryName returns the name of a binary for the given tool or an error if the tool's template cannot be parsed or executed.
func GetClientArch ¶
func GetClientArch() (arch, os string)
GetClientArch retrieves the host systems architecture and operating system. It will change the naming to a consistent format for linux/amd64. Further transformations of the architecture and operating system are then done elsewhere from a common base.
func GetDownloadURL ¶
GetDownloadURL returns the downloadable assets from GitHub for use in other functions.
func InitUserDir ¶
InitUserDir will establish a location for the binaries to be stored.
func ListToolsTable ¶
func ListToolsTable(tools Tools)
ListToolsTable returns a list of all supported tools in tabular format.
func LocalBinary ¶
LocalBinary returns the filepath for the binary in the users home directory.
func PostInstallationMessage ¶
PostInstallationMessage generates installation message after tool has been downloaded
func PrintPostInstallMessage ¶
Types ¶
type GithubAPIReleasesResponse ¶
type GithubAPIReleasesResponse struct { Url string `json:"url"` AssetsUrl string `json:"assets_url"` UploadUrl string `json:"upload_url"` HtmlUrl string `json:"html_url"` Id int `json:"id"` Author struct { Login string `json:"login"` Id int `json:"id"` NodeId string `json:"node_id"` AvatarUrl string `json:"avatar_url"` GravatarId string `json:"gravatar_id"` Url string `json:"url"` HtmlUrl string `json:"html_url"` FollowersUrl string `json:"followers_url"` FollowingUrl string `json:"following_url"` GistsUrl string `json:"gists_url"` StarredUrl string `json:"starred_url"` SubscriptionsUrl string `json:"subscriptions_url"` OrganizationsUrl string `json:"organizations_url"` ReposUrl string `json:"repos_url"` EventsUrl string `json:"events_url"` ReceivedEventsUrl string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` } `json:"author"` NodeId string `json:"node_id"` TagName string `json:"tag_name"` TargetCommitish string `json:"target_commitish"` Name string `json:"name"` Draft bool `json:"draft"` Prerelease bool `json:"prerelease"` CreatedAt time.Time `json:"created_at"` PublishedAt time.Time `json:"published_at"` Assets []struct { Url string `json:"url"` Id int `json:"id"` NodeId string `json:"node_id"` Name string `json:"name"` Label string `json:"label"` Uploader struct { Login string `json:"login"` Id int `json:"id"` NodeId string `json:"node_id"` AvatarUrl string `json:"avatar_url"` GravatarId string `json:"gravatar_id"` Url string `json:"url"` HtmlUrl string `json:"html_url"` FollowersUrl string `json:"followers_url"` FollowingUrl string `json:"following_url"` GistsUrl string `json:"gists_url"` StarredUrl string `json:"starred_url"` SubscriptionsUrl string `json:"subscriptions_url"` OrganizationsUrl string `json:"organizations_url"` ReposUrl string `json:"repos_url"` EventsUrl string `json:"events_url"` ReceivedEventsUrl string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` } `json:"uploader"` ContentType string `json:"content_type"` State string `json:"state"` Size int `json:"size"` DownloadCount int `json:"download_count"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` BrowserDownloadUrl string `json:"browser_download_url"` } `json:"assets"` TarballUrl string `json:"tarball_url"` ZipballUrl string `json:"zipball_url"` Body string `json:"body"` MentionsCount int `json:"mentions_count,omitempty"` }
GithubAPIReleasesResponse is taken from the GitHub Releases API ref: https://docs.github.com/en/rest/releases/releases#list-releases
func FindGithubRelease ¶
func FindGithubRelease(owner, repo string) ([]*GithubAPIReleasesResponse, error)
FindGithubRelease retrieves a response from GitHub's API for any valid repository in JSON format.
type Tool ¶
type Tool struct { // Name of the tool Name string // Repo is the GitHub repo Repo string // Owner is the tool Repo owner, such as // derailed/k9s Owner string // Version to pull. An empty string means "latest" Version string // Description of what this tool does/is. Description string // NonBinary is used to determine if the tool is not a binary such as // kubetail which is a bash script NonBinary bool // BinaryTemplate is the naming convention for a binary from GitHub. // Using runtime.GOOS and runtime.GOARCH it is possible to determine the // binary name, and BinaryTemplate must match it. BinaryTemplate string // URLTemplate specifies a Go template for the download URL // override the OS, architecture and extension // All whitespace will be trimmed URLTemplate string }