github

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 6 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) *Client

New creates a new GitHub API client.

The passed http.Client should be configured

func (*Client) LatestRelease

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

LatestRelease details for a GitHub repository.

func (*Client) PrepareDownload

func (a *Client) PrepareDownload(asset Asset) (client *http.Client, req *http.Request, err error)

PrepareDownload prepares a HTTP client and request for retrieving a file from GitHub.

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

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

Releases for a particular repo.

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"`
}

Repo information.

Jump to

Keyboard shortcuts

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