Documentation
¶
Index ¶
Constants ¶
const ( // MinRepositoryCountGoal - number of repositories required to receive the maximum rate limit. // "Installations that have more than 20 repositories receive another 50 requests per hour for each repository. The maximum rate limit for an installation is 12,500 requests per hour." // // (20 + 7500 // 50) // // Ref: https://docs.github.com/en/free-pro-team@latest/developers/apps/differences-between-github-apps-and-oauth-apps MinRepositoryCountGoal = 170 // MinGitHubRateLimit - "GitHub Apps making server-to-server requests use the installation's // minimum rate limit of 5,000 requests per hour." // // Ref: https://docs.github.com/en/free-pro-team@latest/developers/apps/differences-between-github-apps-and-oauth-apps MinGitHubRateLimit = 5000 // MaxGitHubRateLimit - the maximum rate limit for GitHub API requests in apps MaxGitHubRateLimit = 12500 )
Variables ¶
var ( // DefaultContext represents context.Background() which is a non-nil empty context that is // never canceled, has no values, and has no deadline. It is typically used by the main // function, initialization, and tests, and as the top-level Context for incoming requests. DefaultContext context.Context = context.Background() )
Functions ¶
func AuthClient ¶
AuthClient returns an authenticated *http.Client for use with API requests. It relies on getEnvToken to collect a secure Personal API Token (PAT) from an environment variable or other secure source.
If authentication fails, AuthClient falls back and returns http.DefaultClient with no authentication. Any error is also returned; calling func has a choice of action.
Most users will pass in ctx := DefaultContext which represents context.Background(). It is a non-nil empty context that is never canceled, has no values, and has no deadline. It is typically used by the main function, initialization, and tests, and as the top-level Context for incoming requests.
func GetEnvToken ¶
func GetEnvToken() (oauth2.TokenSource, error)
GetEnvToken - get PAT from environment variable (const envGitTokenKey) global tokenSource is used to cache
func NewGitHubClient ¶
NewGitHubClient returns a pointer to a new authenticated GitHub client
Environment variables can be used for authentication:
username = GIT_AUTHOR_NAME
password = GITHUB_API_TOKEN_VSCODE
Most users will pass in ctx := DefaultContext which represents context.Background(). It is a non-nil empty context that is never canceled, has no values, and has no deadline. It is typically used by the main function, initialization, and tests, and as the top-level Context for incoming requests.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
_example
|
|
|
cmd/github-client
command
|
|
|
cmd/gogithub
command
The basicauth command demonstrates using the github.BasicAuthTransport, including handling two-factor authentication.
|
The basicauth command demonstrates using the github.BasicAuthTransport, including handling two-factor authentication. |
|
escape-seq
command
|
|
|
logrus
command
|
|
|
title
command
|