gupdate

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

gupdate

Create self updating binaries

Background

This package wraps Minio's self updater package and allows for automatic downloading of Go binaries.

Usage

Create a project and then use gupdate to get the latest release and update the binary.

gh := gupdate.GitHubProject{
	Name:     "coverwhale-go",
	Owner:    "CoverWhale",
	Platform: runtime.GOOS,
	Arch:     runtime.GOARCH,
	ChecksumFunc: gupdate.GoReleaserChecksum,
}

release, err := gupdate.GetLatestRelease(gh)
if err != nil {
	log.Fatal(err)
}

if err := release.Update(); err != nil {
	log.Fatal(err)
}

Private Repos

For GitHub projects there is a Token field on the GitHubProject struct. This will automatically add the token to the request and use the correct headers.

It sets a RequestFunc under the hood which sets the token and accept types. This can be overridden if needed on both the GitHubProject and the Release.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoReleaserChecksum added in v0.0.2

func GoReleaserChecksum(r io.Reader) (string, error)

Types

type AllReleasesGetter added in v0.0.2

type AllReleasesGetter interface {
	// contains filtered or unexported methods
}

type CheckSumGetter

type CheckSumGetter interface {
	GetChecksum(io.Reader) (string, error)
}

type ChecksumFunc added in v0.0.2

type ChecksumFunc func(io.Reader) (string, error)

type GitHubAssets

type GitHubAssets struct {
	URL                string         `json:"url,omitempty"`
	ID                 int            `json:"id,omitempty"`
	NodeID             string         `json:"node_id,omitempty"`
	Name               string         `json:"name,omitempty"`
	Label              string         `json:"label,omitempty"`
	Uploader           GitHubUploader `json:"uploader,omitempty"`
	ContentType        string         `json:"content_type,omitempty"`
	State              string         `json:"state,omitempty"`
	Size               int            `json:"size,omitempty"`
	DownloadCount      int            `json:"download_count,omitempty"`
	CreatedAt          time.Time      `json:"created_at,omitempty"`
	UpdatedAt          time.Time      `json:"updated_at,omitempty"`
	BrowserDownloadURL string         `json:"browser_download_url,omitempty"`
}

type GitHubAuthor

type GitHubAuthor struct {
	Login             string `json:"login,omitempty"`
	ID                int    `json:"id,omitempty"`
	NodeID            string `json:"node_id,omitempty"`
	AvatarURL         string `json:"avatar_url,omitempty"`
	GravatarID        string `json:"gravatar_id,omitempty"`
	URL               string `json:"url,omitempty"`
	HTMLURL           string `json:"html_url,omitempty"`
	FollowersURL      string `json:"followers_url,omitempty"`
	FollowingURL      string `json:"following_url,omitempty"`
	GistsURL          string `json:"gists_url,omitempty"`
	StarredURL        string `json:"starred_url,omitempty"`
	SubscriptionsURL  string `json:"subscriptions_url,omitempty"`
	OrganizationsURL  string `json:"organizations_url,omitempty"`
	ReposURL          string `json:"repos_url,omitempty"`
	EventsURL         string `json:"events_url,omitempty"`
	ReceivedEventsURL string `json:"received_events_url,omitempty"`
	Type              string `json:"type,omitempty"`
	SiteAdmin         bool   `json:"site_admin,omitempty"`
}

type GitHubProject

type GitHubProject struct {
	Owner        string `json:"owner"`
	Name         string `json:"name,omitempty"`
	Platform     string `json:"platform"`
	Arch         string `json:"arch"`
	ChecksumFunc ChecksumFunc
	Token        string
	ReqFunc      RequestFunc
}

type GitHubRelease

type GitHubRelease struct {
	URL             string         `json:"url,omitempty"`
	AssetsURL       string         `json:"assets_url,omitempty"`
	UploadURL       string         `json:"upload_url,omitempty"`
	HTMLURL         string         `json:"html_url,omitempty"`
	ID              int            `json:"id,omitempty"`
	Author          GitHubAuthor   `json:"author,omitempty"`
	NodeID          string         `json:"node_id,omitempty"`
	TagName         string         `json:"tag_name,omitempty"`
	TargetCommitish string         `json:"target_commitish,omitempty"`
	Name            string         `json:"name,omitempty"`
	Draft           bool           `json:"draft,omitempty"`
	Prerelease      bool           `json:"prerelease,omitempty"`
	CreatedAt       time.Time      `json:"created_at,omitempty"`
	PublishedAt     time.Time      `json:"published_at,omitempty"`
	Assets          []GitHubAssets `json:"assets,omitempty"`
	TarballURL      string         `json:"tarball_url,omitempty"`
	ZipballURL      string         `json:"zipball_url,omitempty"`
	Body            string         `json:"body,omitempty"`
}

type GitHubReleases

type GitHubReleases []GitHubRelease

type GitHubUploader

type GitHubUploader struct {
	Login             string `json:"login,omitempty"`
	ID                int    `json:"id,omitempty"`
	NodeID            string `json:"node_id,omitempty"`
	AvatarURL         string `json:"avatar_url,omitempty"`
	GravatarID        string `json:"gravatar_id,omitempty"`
	URL               string `json:"url,omitempty"`
	HTMLURL           string `json:"html_url,omitempty"`
	FollowersURL      string `json:"followers_url,omitempty"`
	FollowingURL      string `json:"following_url,omitempty"`
	GistsURL          string `json:"gists_url,omitempty"`
	StarredURL        string `json:"starred_url,omitempty"`
	SubscriptionsURL  string `json:"subscriptions_url,omitempty"`
	OrganizationsURL  string `json:"organizations_url,omitempty"`
	ReposURL          string `json:"repos_url,omitempty"`
	EventsURL         string `json:"events_url,omitempty"`
	ReceivedEventsURL string `json:"received_events_url,omitempty"`
	Type              string `json:"type,omitempty"`
	SiteAdmin         bool   `json:"site_admin,omitempty"`
}

type LatestReleaseGetter added in v0.0.2

type LatestReleaseGetter interface {
	// contains filtered or unexported methods
}

type Release

type Release struct {
	Checksum string `json:"checksum,omitempty"`
	URL      string `json:"url"`
	ReqFunc  RequestFunc
}

func GetAllReleases

func GetAllReleases(r AllReleasesGetter) ([]Release, error)

func GetLatestRelease

func GetLatestRelease(r LatestReleaseGetter) (Release, error)

func (Release) Update

func (r Release) Update() error

type RequestFunc added in v0.0.2

type RequestFunc func(r *http.Request)

func GitHubReqFunc added in v0.0.2

func GitHubReqFunc(token, accept string) RequestFunc

Jump to

Keyboard shortcuts

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