Fix docker versioning library to support new versioning scheme
Fixes: https://sentry.io/coreos/backend-production/issues/222349174/ Reference: https://github.com/docker/docker/pull/31075
This commit is contained in:
parent
94be8731f3
commit
67c0bf6263
2 changed files with 19 additions and 2 deletions
|
@ -16,7 +16,14 @@ def docker_version(user_agent_string):
|
|||
# First search for a well defined semver portion in the UA header.
|
||||
found_semver = _USER_AGENT_SEARCH_REGEX.search(user_agent_string)
|
||||
if found_semver:
|
||||
return Version(found_semver.group(1), partial=True)
|
||||
# Docker changed their versioning scheme on Feb 17, 2017 to use date-based versioning:
|
||||
# https://github.com/docker/docker/pull/31075
|
||||
|
||||
# This scheme allows for 0s to appear as prefixes in the major or minor portions of the version,
|
||||
# which violates semver. Strip them out.
|
||||
portions = found_semver.group(1).split('.')
|
||||
updated_portions = [(p[:-1].lstrip('0') + p[-1]) for p in portions]
|
||||
return Version('.'.join(updated_portions), partial=True)
|
||||
|
||||
# Check if we received the very specific header which represents a 1.5 request
|
||||
# to the auth endpoints.
|
||||
|
|
Reference in a new issue