github

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package github implements a client for GitHub that includes the minimum set of functions required by Hermit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TokenAuthenticatedTransport

func TokenAuthenticatedTransport(transport http.RoundTripper, token string) http.RoundTripper

TokenAuthenticatedTransport returns a HTTP transport that will inject a GitHub authentication token into any requests to github.com.

Conceptually similar to https://github.com/google/go-github/blob/d23570d44313ca73dbcaadec71fc43eca4d29f8b/github/github.go#L841-L875

Types

type Asset

type Asset struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Asset is a minimal type for assets in the GitHub releases meta information retrieved via the GitHub API.

See https://docs.github.com/en/rest/reference/repos#list-releases

type Client

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

Client for GitHub.

func New

func New(client *http.Client, token string) *Client

New creates a new GitHub API client.

func (*Client) Download added in v0.3.3

func (a *Client) Download(asset Asset) (resp *http.Response, err error)

Download creates a download request for retrieving a release asset from GitHub.

func (*Client) ETag added in v0.10.0

func (a *Client) ETag(asset Asset) (etag string, err error)

ETag issues a HEAD request for an Asset and returns its ETag.

func (*Client) LatestRelease

func (a *Client) LatestRelease(repo string) (*Release, error)

LatestRelease details for a GitHub repository.

func (*Client) ProjectForURL

func (a *Client) ProjectForURL(sourceURL string) string

ProjectForURL returns the <repo>/<project> for the given URL if it is a GitHub project.

func (*Client) Release added in v0.10.0

func (a *Client) Release(repo, tag string) (*Release, error)

Release attempts to fetch Release info for a tag.

func (*Client) Releases

func (a *Client) Releases(repo string, limit int) (releases []*Release, err error)

Releases for a particular repo. If limit is 0, fetches all releases.

func (*Client) Repo

func (a *Client) Repo(repo string) (*Repo, error)

Repo information.

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	Assets  []Asset `json:"assets"`
}

Release is a minimal type for GitHub releases meta information retrieved via the GitHub API.

See https://docs.github.com/en/rest/reference/repos#list-releases

type Repo

type Repo struct {
	Description string `json:"description"`
	Homepage    string `json:"homepage"`
}

Repo information.

Jump to

Keyboard shortcuts

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