Kaydet (Commit) 3062ae43 authored tarafından Tomas Tomecek's avatar Tomas Tomecek Kaydeden (comit) Joffrey F

docker client consistency: don't quote ':/'

E.g.

docker client

`/v1.21/images/localhost:5000/busybox/push?tag=`

docker-py

`/v1.21/images/localhost%3A5000%2Fbusybox/push`
Signed-off-by: 's avatarTomas Tomecek <ttomecek@redhat.com>
üst 95d9306d
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
import json import json
import struct import struct
from functools import partial
import requests import requests
import requests.exceptions import requests.exceptions
...@@ -157,7 +158,8 @@ class Client( ...@@ -157,7 +158,8 @@ class Client(
'instead'.format(arg, type(arg)) 'instead'.format(arg, type(arg))
) )
args = map(six.moves.urllib.parse.quote_plus, args) quote_f = partial(six.moves.urllib.parse.quote_plus, safe="/:")
args = map(quote_f, args)
if kwargs.get('versioned_api', True): if kwargs.get('versioned_api', True):
return '{0}/v{1}{2}'.format( return '{0}/v{1}{2}'.format(
......
...@@ -159,9 +159,15 @@ class DockerApiTest(DockerClientTest): ...@@ -159,9 +159,15 @@ class DockerApiTest(DockerClientTest):
'{0}{1}'.format(url_prefix, 'hello/somename/world/someothername') '{0}{1}'.format(url_prefix, 'hello/somename/world/someothername')
) )
url = self.client._url('/hello/{0}/world', '/some?name') url = self.client._url('/hello/{0}/world', 'some?name')
self.assertEqual( self.assertEqual(
url, '{0}{1}'.format(url_prefix, 'hello/%2Fsome%3Fname/world') url, '{0}{1}'.format(url_prefix, 'hello/some%3Fname/world')
)
url = self.client._url("/images/{0}/push", "localhost:5000/image")
self.assertEqual(
url,
'{0}{1}'.format(url_prefix, 'images/localhost:5000/image/push')
) )
def test_url_invalid_resource(self): def test_url_invalid_resource(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment