github

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package github provides an implementation of the provider.Client interface for the GitHub REST API.

Index

Constants

This section is empty.

Variables

View Source
var (
	PullRequestActions = map[string]struct{}{
		"opened":      {},
		"reopened":    {},
		"unlocked":    {},
		"synchronize": {},
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	provider.BaseClient
}

func New

func New(host, endpoint, secret, clientId, clientSecret string) *Client

New returns a new Client to the GitHub REST API. If the given endpoint is empty then the default "https://api.github.com" will be used. This will set the following scopes to request: "admin:repo_hook", "read:org", "repo".

func (*Client) Groups

func (g *Client) Groups(tok string) ([]int64, error)

Groups implements the provider.Client interface. For GitHub this will return a slice of the organization IDs the user is either an owner of, or a member of.

func (*Client) Repos

func (g *Client) Repos(tok string, page int64) ([]*provider.Repo, database.Paginator, error)

Repos implements the provider.Client interface.

func (*Client) SetCommitStatus

func (g *Client) SetCommitStatus(tok string, r *provider.Repo, status runner.Status, url, sha string) error

SetCommitStatus implements the provider.Client interface.

func (*Client) ToggleRepo

func (g *Client) ToggleRepo(tok string, r *provider.Repo) error

ToggleRepo implementas the provider.Client interface.

func (*Client) VerifyRequest

func (g *Client) VerifyRequest(r io.Reader, signature string) ([]byte, error)

VerifyRequest implements the provider.Client interface.

type Error

type Error struct {
	Message string              // Message is the original message from a failed request.
	Errors  []map[string]string // Errors is the list of errors that occurred from a failed request.
}

func (Error) Error

func (e Error) Error() string

Error returns a formatted string of an error from the GitHub API.

func (Error) Has

func (e Error) Has(err1 string) bool

Has reports whether or not the given error string exists in the underlying error.

type PullRequestEvent

type PullRequestEvent struct {
	Action      string
	Number      int64
	PullRequest struct {
		Title   string
		User    User
		HTMLURL string `json:"html_url"`
		Head    struct {
			Sha  string
			User User
			Repo Repo
		}
		Base struct {
			Ref  string
			User User
			Repo Repo
		}
	} `json:"pull_request"`
}

type PushEvent

type PushEvent struct {
	Ref        string
	Repo       Repo `json:"repository"`
	HeadCommit struct {
		ID      string
		URL     string
		Message string
		Author  map[string]string
	} `json:"head_commit"`
}

type Repo

type Repo struct {
	ID          int64
	Owner       User
	FullName    string `json:"full_name"`
	HTMLURL     string `json:"html_url"`
	ContentsURL string `json:"contents_url"`
}

type User

type User struct {
	ID    int64
	Login string
}

Jump to

Keyboard shortcuts

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