Documentation
¶
Overview ¶
Package github integrates shed with a single GitHub App.
The App provides everything shed needs from GitHub: repository access through installation tokens, sign-in through OAuth, push webhooks, and CI status. REST calls go through go-github.
Index ¶
- func Manifest(baseURL, name string) ([]byte, error)
- func VerifySignature(secret string, body []byte, header string) bool
- type App
- type CIState
- type Client
- func (c *Client) App() App
- func (c *Client) AuthorizeURL(redirectURL, state string) string
- func (c *Client) Branches(ctx context.Context, fullName string) ([]string, error)
- func (c *Client) CIStatus(ctx context.Context, fullName, sha string) (CIState, error)
- func (c *Client) CloneURL(ctx context.Context, fullName string) (string, error)
- func (c *Client) Commit(ctx context.Context, fullName, ref string) (Commit, error)
- func (c *Client) ExchangeUser(ctx context.Context, code, redirectURL string) (User, error)
- func (c *Client) Lookup(ctx context.Context) (slug, clientID string, err error)
- func (c *Client) Repos(ctx context.Context) ([]Repo, error)
- type Commit
- type PushEvent
- type Repo
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
ID int64
Slug string
ClientID string
ClientSecret string
WebhookSecret string
// PrivateKey is the PEM-encoded RSA key used to sign app JWTs.
PrivateKey []byte
}
App holds the credentials of a registered GitHub App.
type CIState ¶
type CIState string
CIState is the aggregate state of the CI results for a commit.
const ( // CIPending means some check or status has not finished and none failed. CIPending CIState = "pending" // CISuccess means every check and status passed. CISuccess CIState = "success" // CIFailure means at least one check or status failed. CIFailure CIState = "failure" // CINone means the commit has no checks or statuses. Checks may simply // not have been created yet. CINone CIState = "none" )
CI states.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the GitHub API as an App. It is safe for concurrent use.
func New ¶
New returns a Client for app. A nil httpClient means a client with a 30-second timeout. The client is never modified.
func (*Client) AuthorizeURL ¶
AuthorizeURL returns the GitHub page that asks a user to authorize the App. GitHub redirects back to redirectURL with the code and state.
func (*Client) Branches ¶
Branches returns the branch names of the repository fullName (owner/name).
func (*Client) CIStatus ¶
CIStatus combines the check runs and commit statuses of commit sha in the repository fullName (owner/name). A failure outranks pending results, so callers can stop waiting as soon as anything fails.
func (*Client) CloneURL ¶
CloneURL returns an HTTPS URL for cloning the repository fullName (owner/name) that embeds a short-lived installation token. It is a secret.
func (*Client) Commit ¶
Commit returns the commit that ref, a branch name or SHA, points to in the repository fullName (owner/name).
func (*Client) ExchangeUser ¶
ExchangeUser trades the code from an authorization redirect for a user token and returns the user it belongs to. redirectURL must match the one given to Client.AuthorizeURL.
type Commit ¶
type Commit struct {
SHA string
// Message is the first line of the commit message.
Message string
Author string
}
Commit describes a git commit.
type PushEvent ¶
type PushEvent struct {
// Repo is the repository as owner/name.
Repo string
// Branch is the pushed branch, or empty if the ref is not a branch.
Branch string
// SHA is the new head commit.
SHA string
// Message is the first line of the head commit's message.
Message string
// Author is the head commit's author name.
Author string
// Deleted reports that the push deleted the branch.
Deleted bool
}
PushEvent is the part of a push webhook payload shed acts on.