github

package
v0.10.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package github implements a client SDK for the Github API.

Index

Constants

View Source
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.

View Source
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
)
View Source
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.

func OIDCToken added in v0.5.0

func OIDCToken(ctx context.Context, cfg OIDCVars) (token string, err error)

OIDCToken requests a new OIDC token.

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.

type OIDCVars

type OIDCVars struct {
	ReqURL   string
	ReqToken string
}

OIDCVars is the variables used for issuing new OIDC tokens.

Jump to

Keyboard shortcuts

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