Documentation ¶
Index ¶
- func GetArchive(ctx context.Context, c *http.Client, url string) (_ string, err error)
- func ListInstallations(ctx context.Context, c *github.Client, ...) error
- func ListRepos(ctx context.Context, c *github.Client, ...) error
- func NewOAuthEndpoint(u *url.URL) oauth2.Endpoint
- type AppTokenSource
- type Connector
- type InstallationTokenSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetArchive ¶
GetArchive downloads and uncompresses a source archive from GitHub.
It returns the name of a temporary directory containing the root of the repository.
func ListInstallations ¶
func ListInstallations( ctx context.Context, c *github.Client, fn func(context.Context, *github.Installation) error, ) error
ListInstallations calls fn for each installation of the application.
Types ¶
type AppTokenSource ¶
type AppTokenSource struct { // AppID is the GitHub application ID. AppID int64 // PrivateKey is the application's private key. PrivateKey *rsa.PrivateKey // TTL is the default amount of time that each token remains valid. // If it is non-positive, a value of 1 minute is used. TTL time.Duration }
AppTokenSource is an implementation of oauth2.TokenSource that generates GitHub API tokens that authenticate as a GitHub application.
type Connector ¶
type Connector struct { // AppClient is a GitHub client that is setup to authenticate using the // GitHub application's credentials. AppClient *github.Client // OAuthConfig is the OAuth configuration for the application. It may be nil // if the application does not authenticate or act on behalf of GitHub // users. OAuthConfig *oauth2.Config // Permissions optionally limits the client's permissions to a subset of // those available to the application. // // If it is nil, the full set of permissions granted to the application are // granted to each new client. Permissions *github.InstallationPermissions // Transport is the HTTP transport used by GitHub clients created by the // connector. If it is nil the default transport is used. Transport http.RoundTripper }
Connector creates GitHub clients with different authentication credentials on behalf of a GitHub application.
func NewConnector ¶
func NewConnector( appID int64, appKey *rsa.PrivateKey, clientID string, clientSecret string, baseURL *url.URL, transport http.RoundTripper, ) (*Connector, error)
NewConnector returns a new connector.
This is a convenience function that configures the connector with useful defaults.
clientID is the OAuth client ID. If it is empty the OAuth configuration is omitted.
baseURL is the base URL for the API of a GitHub Enterprise Server installation. If it is nil or empty the connector uses github.com.
transport is the HTTP transport used by the GitHub clients created by the connector. If it is nil the default HTTP transport is used.
func (*Connector) InstallationClient ¶
InstallationClient returns a GitHub client that is authenticated as a specific installation of a GitHub application.
func (*Connector) RepositoryClient ¶
RepositoryClient returns a GitHub client that is authenticated as a the installation of a GitHub application that grants the application access to a specific repository.
The client uses an access token that is only granted access to the specified repository.
type InstallationTokenSource ¶
type InstallationTokenSource struct { // AppClient is a GitHub client that is authenticated as the application // itself. See AppTokenSource. AppClient *github.Client // InstallationID is the ID of the installation. InstallationID int64 // Options is a set of options to use when generating installation-specific // tokens. Options *github.InstallationTokenOptions // RequestTimeout is the amount of time to allow for token generation via // the GitHub client. If it is non-positive, a value of 10 seconds is used. RequestTimeout time.Duration }
InstallationTokenSource is an implementation of oauth2.TokenSource that generates GitHub API tokens that authenticate a specific installation of a GitHub application.