mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-04 12:37:59 +00:00
Bump deps
This commit is contained in:
40
vendor/github.com/google/go-github/github/github.go
generated
vendored
40
vendor/github.com/google/go-github/github/github.go
generated
vendored
@@ -87,6 +87,12 @@ const (
|
||||
|
||||
// https://developer.github.com/v3/repos/traffic/
|
||||
mediaTypeTrafficPreview = "application/vnd.github.spiderman-preview+json"
|
||||
|
||||
// https://developer.github.com/changes/2016-09-14-projects-api/
|
||||
mediaTypeProjectsPreview = "application/vnd.github.inertia-preview+json"
|
||||
|
||||
// https://developer.github.com/changes/2016-09-14-Integrations-Early-Access/
|
||||
mediaTypeIntegrationPreview = "application/vnd.github.machine-man-preview+json"
|
||||
)
|
||||
|
||||
// A Client manages communication with the GitHub API.
|
||||
@@ -117,6 +123,7 @@ type Client struct {
|
||||
Gists *GistsService
|
||||
Git *GitService
|
||||
Gitignores *GitignoresService
|
||||
Integrations *IntegrationsService
|
||||
Issues *IssuesService
|
||||
Organizations *OrganizationsService
|
||||
PullRequests *PullRequestsService
|
||||
@@ -187,6 +194,7 @@ func NewClient(httpClient *http.Client) *Client {
|
||||
c.Gists = (*GistsService)(&c.common)
|
||||
c.Git = (*GitService)(&c.common)
|
||||
c.Gitignores = (*GitignoresService)(&c.common)
|
||||
c.Integrations = (*IntegrationsService)(&c.common)
|
||||
c.Issues = (*IssuesService)(&c.common)
|
||||
c.Licenses = (*LicensesService)(&c.common)
|
||||
c.Migrations = (*MigrationService)(&c.common)
|
||||
@@ -491,6 +499,24 @@ func (r *RateLimitError) Error() string {
|
||||
r.Response.StatusCode, r.Message, r.Rate.Reset.Time.Sub(time.Now()))
|
||||
}
|
||||
|
||||
// AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the
|
||||
// "documentation_url" field value equal to "https://developer.github.com/v3#abuse-rate-limits".
|
||||
type AbuseRateLimitError struct {
|
||||
Response *http.Response // HTTP response that caused this error
|
||||
Message string `json:"message"` // error message
|
||||
|
||||
// RetryAfter is provided with some abuse rate limit errors. If present,
|
||||
// it is the amount of time that the client should wait before retrying.
|
||||
// Otherwise, the client should try again later (after an unspecified amount of time).
|
||||
RetryAfter *time.Duration
|
||||
}
|
||||
|
||||
func (r *AbuseRateLimitError) Error() string {
|
||||
return fmt.Sprintf("%v %v: %d %v",
|
||||
r.Response.Request.Method, sanitizeURL(r.Response.Request.URL),
|
||||
r.Response.StatusCode, r.Message)
|
||||
}
|
||||
|
||||
// sanitizeURL redacts the client_secret parameter from the URL which may be
|
||||
// exposed to the user, specifically in the ErrorResponse error message.
|
||||
func sanitizeURL(uri *url.URL) *url.URL {
|
||||
@@ -561,6 +587,20 @@ func CheckResponse(r *http.Response) error {
|
||||
Response: errorResponse.Response,
|
||||
Message: errorResponse.Message,
|
||||
}
|
||||
case r.StatusCode == http.StatusForbidden && errorResponse.DocumentationURL == "https://developer.github.com/v3#abuse-rate-limits":
|
||||
abuseRateLimitError := &AbuseRateLimitError{
|
||||
Response: errorResponse.Response,
|
||||
Message: errorResponse.Message,
|
||||
}
|
||||
if v := r.Header["Retry-After"]; len(v) > 0 {
|
||||
// According to GitHub support, the "Retry-After" header value will be
|
||||
// an integer which represents the number of seconds that one should
|
||||
// wait before resuming making requests.
|
||||
retryAfterSeconds, _ := strconv.ParseInt(v[0], 10, 64) // Error handling is noop.
|
||||
retryAfter := time.Duration(retryAfterSeconds) * time.Second
|
||||
abuseRateLimitError.RetryAfter = &retryAfter
|
||||
}
|
||||
return abuseRateLimitError
|
||||
default:
|
||||
return errorResponse
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user