Documentation ¶
Overview ¶
Package github implements a client SDK for the Github API.
Index ¶
Constants ¶
const ( // ErrNotFound indicates the resource does not exists. ErrNotFound errors.Kind = "resource not found (HTTP Status: 404)" // ErrUnprocessableEntity indicates the entity cannot be processed for any reason. ErrUnprocessableEntity errors.Kind = "entity cannot be processed (HTTP Status: 422)" ErrDeviceFlowAuthPending errors.Kind = "the authorization request is still pending" ErrDeviceFlowSlowDown errors.Kind = "too many requests, please slowdown" ErrDeviceFlowAuthUnexpected errors.Kind = "unexpected device flow error" ErrDeviceFlowAuthExpired errors.Kind = "this 'device_code' has expired" ErrDeviceFlowAccessDenied errors.Kind = "user cancelled the authorization flow" ErrDeviceFlowIncorrectCode errors.Kind = "the device code provided is not valid" )
GitHub API errors.
const ( // Domain is the default GitHub domain. Domain = "github.com" // APIDomain is the default GitHub API domain. APIDomain = "api." + Domain // APIBaseURL is the default base url for the GitHub API. APIBaseURL = "https://" + APIDomain )
const ( ErrGithubEventPathEnvNotSet errors.Kind = `environment variable "GITHUB_EVENT_PATH" not set` ErrGithubEventUnmarshal errors.Kind = "failed to unmarshal github event" ErrGithubEventMissingPR errors.Kind = "event does not contain a pull request" )
Errors for when the GitHub event cannot be read.
Variables ¶
This section is empty.
Functions ¶
func GetEventPR ¶ added in v0.5.0
func GetEventPR() (*github.PullRequest, error)
GetEventPR returns the pull request event from the file at GITHUB_EVENT_PATH.
Types ¶
type OAuthDeviceFlowContext ¶ added in v0.6.1
type OAuthDeviceFlowContext struct { UserCode string `json:"user_code"` DeviceCode string `json:"device_code"` VerificationURI string `json:"verification_uri"` Interval int `json:"interval"` ExpiresIn int `json:"expires_in"` // contains filtered or unexported fields }
OAuthDeviceFlowContext holds the context information for an ongoing device authentication flow.
func OAuthDeviceFlowAuthStart ¶ added in v0.6.1
func OAuthDeviceFlowAuthStart(clientID string) (oauthCtx OAuthDeviceFlowContext, err error)
OAuthDeviceFlowAuthStart starts a GitHub device authentication flow. After the flow is started, you need to probe for its state using [ProbeAuthState].
func (*OAuthDeviceFlowContext) ProbeAuthState ¶ added in v0.6.1
func (oauthCtx *OAuthDeviceFlowContext) ProbeAuthState() (string, error)
ProbeAuthState checks the current authentication flow state. This method must be called repeatedly, respecting the oauthCtx.Interval, while it returns ErrDeviceFlowPending or ErrDeviceFlowSlowDown. Eventually, the user will either finish the flow, cancel the process, or the code will expire. When the user finishes the process by providing the correct code, this method returns the access_token and no error.