Skip to content

Commit

Permalink
utils: Limit scope of limit variable
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed May 31, 2023
1 parent 3c6a83f commit 9290444
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def prepare_initrd(architecture, rootfs_format='cpio'):
# First, make sure that the current user is not rate limited by GitHub,
# otherwise the next API call will not return valid information.
gh_json_rl = get_gh_json('https://api.github.com/rate_limit')
limit = gh_json_rl['resources']['core']['limit']
remaining = gh_json_rl['resources']['core']['remaining']

# If we have API calls remaining, we can query for the latest release to
Expand All @@ -206,6 +205,7 @@ def prepare_initrd(architecture, rootfs_format='cpio'):
if cur_rel != latest_rel:
download_initrd(gh_json_rel, src)
elif not src.exists():
limit = gh_json_rl['resources']['core']['limit']
raise RuntimeError(
f"Cannot query GitHub API for latest images release due to rate limit (remaining: {remaining}, limit: {limit}) and {src} does not exist already! "
'Download it manually or supply a GitHub personal access token via the GITHUB_TOKEN environment variable to make an authenticated GitHub API request.'
Expand Down

0 comments on commit 9290444

Please sign in to comment.