Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Make requests to docker registry with bearer tokens #121

Merged
merged 1 commit into from
Feb 3, 2016

Conversation

asmacdo
Copy link
Contributor

@asmacdo asmacdo commented Jan 28, 2016

closes: #1144

https://pulp.plan.io/issues/1596
https://pulp.plan.io/issues/1144

Note: This will hang indefinitely due to https://pulp.plan.io/issues/1567, so Nectar will need to be rebuilt for this to function correctly. @ipanova

"""
If the download fails due to a 401, attempt to retreive a token and try again.
"""
if report.error_report.get('response_code') == 401:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like referencing values from httplib, which in this case would be httplib.UNAUTHORIZED, just to be extra-explicit about context for what the value is and what it means. But it's probably just a matter of taste. No need to change unless you want to.

query_dict = urlparse.parse_qs(parse_result.query)
query_dict.update(auth_info)
url_pieces = list(parse_result)
url_pieces[4] = urllib.urlencode(query_dict)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pain in the ass, but for the sake of readability I'd rather see this either be spelled out, e.g. url_pieces = [parse_result.scheme, parse_result.hostname, ...], or just throw a comment along the lines of # replace the parsed query string, urlpieces[4]

@tehsmyers tehsmyers added the LGTM label Feb 3, 2016
asmacdo added a commit that referenced this pull request Feb 3, 2016
Make requests to docker registry with bearer tokens
@asmacdo asmacdo merged commit e3026ec into pulp:master Feb 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants