-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Description
Description
Currently, we call the GitHub API with GET method to get info about latest release from
https://api.github.com/repos/{repo}/releases/latest
Lines 46 to 76 in c7ccd13
func getLatestReleaseInfo(ctx context.Context, repo string) (*ReleaseInfoResponse, error) { | |
url := fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", repo) | |
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, http.NoBody) | |
if err != nil { | |
return nil, err | |
} | |
req.Header.Add("Accept", "application/vnd.github+json") | |
resp, err := http.DefaultClient.Do(req) | |
if err != nil { | |
return nil, err | |
} | |
defer resp.Body.Close() | |
rawBody, err := io.ReadAll(resp.Body) | |
if err != nil { | |
return nil, err | |
} | |
if resp.StatusCode != http.StatusOK { | |
return nil, fmt.Errorf("got unexpected status code %v", resp.Status) | |
} | |
var latestRelease ReleaseInfoResponse | |
err = json.Unmarshal(rawBody, &latestRelease) | |
if err != nil { | |
return nil, err | |
} | |
return &latestRelease, nil | |
} |
This results in 403 when we hit the quota.
The faas-cli
. Does something similar but uses HEAD method on
https://github.com/{repo}/releases/latest
As a result, the rate limiting is omitted.
This has only one downside. We don't get the PublishedAt
field, because of that I had to remove it from the 1.1.0 version.
Reasons
Avoid rate limiting.
Metadata
Metadata
Assignees
Labels
Projects
Status
Done