github
v1.1.1
Documentation
pkg.go.dev ↗Package github provides an implementation of the provider.Client interface for the GitHub REST API.
Variables
PullRequestActions
var (
PullRequestActions = map[string]struct{}{
"opened": {},
"reopened": {},
"unlocked": {},
"synchronize": {},
}
)
Types
Client
type Client struct {
provider.BaseClient
}
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".
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.
Client.Repos
func (g *Client) Repos(tok string, page int64) ([]*provider.Repo, database.Paginator, error)
Repos implements the provider.Client interface.
Client.SetCommitStatus
func (g *Client) SetCommitStatus(tok string, r *provider.Repo, status runner.Status, url, sha string) error
SetCommitStatus implements the provider.Client interface.
Client.ToggleRepo
func (g *Client) ToggleRepo(tok string, r *provider.Repo) error
ToggleRepo implementas the provider.Client interface.
Client.VerifyRequest
func (g *Client) VerifyRequest(r io.Reader, signature string) ([]byte, error)
VerifyRequest implements the provider.Client interface.
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.
}
Error.Error
func (e Error) Error() string
Error returns a formatted string of an error from the GitHub API.
Error.Has
func (e Error) Has(err1 string) bool
Has reports whether or not the given error string exists in the underlying error.
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"`
}
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"`
}
Repo
type Repo struct {
ID int64
Owner User
FullName string `json:"full_name"`
HTMLURL string `json:"html_url"`
ContentsURL string `json:"contents_url"`
}
User
type User struct {
ID int64
Login string
}