Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
4b090441
Kaydet (Commit)
4b090441
authored
Şub 06, 2014
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #161 from mpetazzoni/api-1.8
Support remote API v1.8 (and make it the default)
üst
417d6912
64f4ba90
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
client.py
docker/client.py
+5
-2
fake_api.py
tests/fake_api.py
+7
-4
test.py
tests/test.py
+9
-1
No files found.
docker/client.py
Dosyayı görüntüle @
4b090441
...
@@ -28,6 +28,7 @@ from .utils import utils
...
@@ -28,6 +28,7 @@ from .utils import utils
if
not
six
.
PY3
:
if
not
six
.
PY3
:
import
websocket
import
websocket
DEFAULT_DOCKER_API_VERSION
=
'1.8'
DEFAULT_TIMEOUT_SECONDS
=
60
DEFAULT_TIMEOUT_SECONDS
=
60
STREAM_HEADER_SIZE_BYTES
=
8
STREAM_HEADER_SIZE_BYTES
=
8
...
@@ -65,7 +66,7 @@ class APIError(requests.exceptions.HTTPError):
...
@@ -65,7 +66,7 @@ class APIError(requests.exceptions.HTTPError):
class
Client
(
requests
.
Session
):
class
Client
(
requests
.
Session
):
def
__init__
(
self
,
base_url
=
None
,
version
=
"1.6"
,
def
__init__
(
self
,
base_url
=
None
,
version
=
DEFAULT_DOCKER_API_VERSION
,
timeout
=
DEFAULT_TIMEOUT_SECONDS
):
timeout
=
DEFAULT_TIMEOUT_SECONDS
):
super
(
Client
,
self
)
.
__init__
()
super
(
Client
,
self
)
.
__init__
()
if
base_url
is
None
:
if
base_url
is
None
:
...
@@ -363,7 +364,7 @@ class Client(requests.Session):
...
@@ -363,7 +364,7 @@ class Client(requests.Session):
if
context
is
not
None
:
if
context
is
not
None
:
context
.
close
()
context
.
close
()
if
stream
:
if
stream
or
utils
.
compare_version
(
'1.8'
,
self
.
_version
)
>=
0
:
return
self
.
_stream_result
(
response
)
return
self
.
_stream_result
(
response
)
else
:
else
:
output
=
self
.
_result
(
response
)
output
=
self
.
_result
(
response
)
...
@@ -473,6 +474,8 @@ class Client(requests.Session):
...
@@ -473,6 +474,8 @@ class Client(requests.Session):
def
images
(
self
,
name
=
None
,
quiet
=
False
,
all
=
False
,
viz
=
False
):
def
images
(
self
,
name
=
None
,
quiet
=
False
,
all
=
False
,
viz
=
False
):
if
viz
:
if
viz
:
if
utils
.
compare_version
(
'1.7'
,
self
.
_version
)
>=
0
:
raise
Exception
(
'Viz output is not supported in API >= 1.7!'
)
return
self
.
_result
(
self
.
_get
(
self
.
_url
(
"images/viz"
)))
return
self
.
_result
(
self
.
_get
(
self
.
_url
(
"images/viz"
)))
params
=
{
params
=
{
'filter'
:
name
,
'filter'
:
name
,
...
...
tests/fake_api.py
Dosyayı görüntüle @
4b090441
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
CURRENT_VERSION
=
'v1.
6
'
CURRENT_VERSION
=
'v1.
8
'
FAKE_CONTAINER_ID
=
'3cc2351ab11b'
FAKE_CONTAINER_ID
=
'3cc2351ab11b'
FAKE_IMAGE_ID
=
'e9aa60c60128'
FAKE_IMAGE_ID
=
'e9aa60c60128'
...
@@ -30,13 +30,16 @@ FAKE_PATH = '/path'
...
@@ -30,13 +30,16 @@ FAKE_PATH = '/path'
def
get_fake_version
():
def
get_fake_version
():
status_code
=
200
status_code
=
200
response
=
{
'GoVersion'
:
'1'
,
'Version'
:
'1.1.1'
}
response
=
{
'GoVersion'
:
'1'
,
'Version'
:
'1.1.1'
,
'GitCommit'
:
'deadbeef+CHANGES'
}
return
status_code
,
response
return
status_code
,
response
def
get_fake_info
():
def
get_fake_info
():
status_code
=
200
status_code
=
200
response
=
{
'Containers'
:
1
,
'Images'
:
1
,
'Debug'
:
''
}
response
=
{
'Containers'
:
1
,
'Images'
:
1
,
'Debug'
:
False
,
'MemoryLimit'
:
False
,
'SwapLimit'
:
False
,
'IPv4Forwarding'
:
True
}
return
status_code
,
response
return
status_code
,
response
...
@@ -52,7 +55,7 @@ def get_fake_images():
...
@@ -52,7 +55,7 @@ def get_fake_images():
'Id'
:
FAKE_IMAGE_ID
,
'Id'
:
FAKE_IMAGE_ID
,
'Created'
:
'2 days ago'
,
'Created'
:
'2 days ago'
,
'Repository'
:
'busybox'
,
'Repository'
:
'busybox'
,
'
Tag'
:
'latest'
'
RepoTags'
:
[
'busybox:latest'
,
'busybox:1.0'
],
}]
}]
return
status_code
,
response
return
status_code
,
response
...
...
tests/test.py
Dosyayı görüntüle @
4b090441
...
@@ -55,7 +55,8 @@ def fake_resp(url, data=None, **kwargs):
...
@@ -55,7 +55,8 @@ def fake_resp(url, data=None, **kwargs):
return
response
(
status_code
=
status_code
,
content
=
content
)
return
response
(
status_code
=
status_code
,
content
=
content
)
fake_request
=
mock
.
Mock
(
side_effect
=
fake_resp
)
fake_request
=
mock
.
Mock
(
side_effect
=
fake_resp
)
url_prefix
=
'http+unix://var/run/docker.sock/v1.6/'
url_prefix
=
'http+unix://var/run/docker.sock/v{0}/'
.
format
(
docker
.
client
.
DEFAULT_DOCKER_API_VERSION
)
@mock.patch.multiple
(
'docker.Client'
,
get
=
fake_request
,
post
=
fake_request
,
@mock.patch.multiple
(
'docker.Client'
,
get
=
fake_request
,
post
=
fake_request
,
...
@@ -103,6 +104,13 @@ class DockerClientTest(unittest.TestCase):
...
@@ -103,6 +104,13 @@ class DockerClientTest(unittest.TestCase):
timeout
=
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
timeout
=
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
)
def
test_image_viz
(
self
):
try
:
self
.
client
.
images
(
'busybox'
,
viz
=
True
)
self
.
fail
(
'Viz output should not be supported!'
)
except
Exception
:
pass
###################
###################
## LISTING TESTS ##
## LISTING TESTS ##
###################
###################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment