gh

package
v0.0.0-...-8ee1375 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRateLimit             = errors.New("rate limit hit")
	ErrAssetNotFound         = errors.New("asset not found")
	ErrUnableToDownloadAsset = errors.New("unable to download asset")
	ErrUnableToReadAsset     = errors.New("unable to download asset")
	ErrFatalError            = errors.New("fatal error using github")
)
View Source
var ErrFieldUnexpectedlyNil = errors.New("expected field to be non-nil")

ErrFieldUnexpectedlyNil is returned when a field that is expected to be non-nil is found to be nil. A lot of GitHub API fields are pointers, so we need to check for nil values.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(token string, opts ...ClientOption) *Client

NewClient creates a new Github Client. If the token is not empty, it will use it as the auth token to make calls.

func (*Client) DownloadFileFromRelease

func (c *Client) DownloadFileFromRelease(
	ctx context.Context,
	owner, repo string,
	httpClient *http.Client,
	filePattern string) (*ReleaseFile, error)

type ClientOption

type ClientOption func(*github.Client)

func WithBaseURL

func WithBaseURL(baseURL *url.URL) ClientOption

type GitHubUser

type GitHubUser struct {
	ID       int64
	Username string
}

type ReleaseFile

type ReleaseFile struct {
	Contents io.ReadCloser
	Info     ReleaseInfo
}

ReleaseFile represents a file in a given Github release.

type ReleaseInfo

type ReleaseInfo struct {
	// If the tag is valid, the will be non null.
	Tag *string
}

type RepoClient

type RepoClient interface {
	GetLatestRelease(ctx context.Context, owner, repo string) (*github.RepositoryRelease, *github.Response, error)
}

type UserEmail

type UserEmail struct {
	Email    string
	Verified bool
}

type UserGitHubClient

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

UserGitHubClient is a client that receives a token from a user that has installed our GitHub App. It uses that token to make requests on behalf of that user to verify things about them. It is different from the regular Client which is used for internal operations.

func NewUserGitHubClient

func NewUserGitHubClient(token string, opts ...ClientOption) *UserGitHubClient

NewUserGitHubClient creates a new UserGitHubClient with the given token. Assumes that the token is not empty.

func (*UserGitHubClient) GetCurrentUser

func (c *UserGitHubClient) GetCurrentUser(ctx context.Context) (*GitHubUser, error)

func (*UserGitHubClient) ListEmails

func (c *UserGitHubClient) ListEmails(ctx context.Context) ([]*UserEmail, error)

type UsersClient

type UsersClient interface {
	ListEmails(ctx context.Context, opts *github.ListOptions) ([]*github.UserEmail, *github.Response, error)
	Get(ctx context.Context, user string) (*github.User, *github.Response, error)
}

Jump to

Keyboard shortcuts

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