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
d19572aa
Kaydet (Commit)
d19572aa
authored
Nis 27, 2017
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Nis 27, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1493 from funkyfuture/model_properties
Adds a few model properties
üst
dec80d91
9536c865
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
18 deletions
+63
-18
.dockerignore
.dockerignore
+1
-2
Dockerfile-docs
Dockerfile-docs
+8
-7
Makefile
Makefile
+2
-2
containers.py
docker/models/containers.py
+18
-0
images.py
docker/models/images.py
+8
-0
containers.rst
docs/containers.rst
+4
-2
images.rst
docs/images.rst
+5
-4
fake_api.py
tests/unit/fake_api.py
+2
-1
models_containers_test.py
tests/unit/models_containers_test.py
+10
-0
models_images_test.py
tests/unit/models_images_test.py
+5
-0
No files found.
.dockerignore
Dosyayı görüntüle @
d19572aa
...
@@ -13,5 +13,4 @@ html/*
...
@@ -13,5 +13,4 @@ html/*
__pycache__
__pycache__
# Compiled Documentation
# Compiled Documentation
site/
docs/_build
Makefile
Dockerfile-docs
Dosyayı görüntüle @
d19572aa
FROM python:3.5
FROM python:3.5
RUN mkdir /src
ARG uid=1000
WORKDIR /src
ARG gid=1000
COPY requirements.txt /src/requirements.txt
RUN addgroup --gid $gid sphinx \
RUN pip install -r requirements.txt
&& useradd --uid $uid --gid $gid -M sphinx
COPY docs-requirements.txt /src/docs-requirements.txt
WORKDIR /src
RUN pip install -r docs-requirements.txt
COPY requirements.txt docs-requirements.txt ./
RUN pip install -r requirements.txt -r docs-requirements.txt
COPY . /src
USER sphinx
Makefile
Dosyayı görüntüle @
d19572aa
...
@@ -16,7 +16,7 @@ build-py3:
...
@@ -16,7 +16,7 @@ build-py3:
.PHONY
:
build-docs
.PHONY
:
build-docs
build-docs
:
build-docs
:
docker build
-t
docker-sdk-python-docs
-f
Dockerfile-docs .
docker build
-t
docker-sdk-python-docs
-f
Dockerfile-docs
--build-arg
uid
=
$(
shell
id
-u
)
--build-arg
gid
=
$(
shell
id
-g
)
.
.PHONY
:
build-dind-certs
.PHONY
:
build-dind-certs
build-dind-certs
:
build-dind-certs
:
...
@@ -77,7 +77,7 @@ flake8: build
...
@@ -77,7 +77,7 @@ flake8: build
.PHONY
:
docs
.PHONY
:
docs
docs
:
build-docs
docs
:
build-docs
docker run
--rm
-it
-v
`
pwd
`
:/
code docker-sdk-python-docs sphinx-build docs .
/_build
docker run
--rm
-it
-v
`
pwd
`
:/
src docker-sdk-python-docs sphinx-build docs docs
/_build
.PHONY
:
shell
.PHONY
:
shell
shell
:
build
shell
:
build
...
...
docker/models/containers.py
Dosyayı görüntüle @
d19572aa
...
@@ -18,6 +18,24 @@ class Container(Model):
...
@@ -18,6 +18,24 @@ class Container(Model):
if
self
.
attrs
.
get
(
'Name'
)
is
not
None
:
if
self
.
attrs
.
get
(
'Name'
)
is
not
None
:
return
self
.
attrs
[
'Name'
]
.
lstrip
(
'/'
)
return
self
.
attrs
[
'Name'
]
.
lstrip
(
'/'
)
@property
def
image
(
self
):
"""
The image of the container.
"""
image_id
=
self
.
attrs
[
'Image'
]
if
image_id
is
None
:
return
None
return
self
.
client
.
images
.
get
(
image_id
.
split
(
':'
)[
1
])
@property
def
labels
(
self
):
"""
The labels of a container as dictionary.
"""
result
=
self
.
attrs
[
'Config'
]
.
get
(
'Labels'
)
return
result
or
{}
@property
@property
def
status
(
self
):
def
status
(
self
):
"""
"""
...
...
docker/models/images.py
Dosyayı görüntüle @
d19572aa
...
@@ -15,6 +15,14 @@ class Image(Model):
...
@@ -15,6 +15,14 @@ class Image(Model):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"<
%
s: '
%
s'>"
%
(
self
.
__class__
.
__name__
,
"', '"
.
join
(
self
.
tags
))
return
"<
%
s: '
%
s'>"
%
(
self
.
__class__
.
__name__
,
"', '"
.
join
(
self
.
tags
))
@property
def
labels
(
self
):
"""
The labels of an image as dictionary.
"""
result
=
self
.
attrs
[
'Config'
]
.
get
(
'Labels'
)
return
result
or
{}
@property
@property
def
short_id
(
self
):
def
short_id
(
self
):
"""
"""
...
...
docs/containers.rst
Dosyayı görüntüle @
d19572aa
...
@@ -21,11 +21,13 @@ Container objects
...
@@ -21,11 +21,13 @@ Container objects
.. autoclass:: Container()
.. autoclass:: Container()
.. py:attribute:: attrs
.. autoattribute:: id
.. autoattribute:: id
.. autoattribute:: short_id
.. autoattribute:: image
.. autoattribute:: labels
.. autoattribute:: name
.. autoattribute:: name
.. autoattribute:: short_id
.. autoattribute:: status
.. autoattribute:: status
.. py:attribute:: attrs
The raw representation of this object from the server.
The raw representation of this object from the server.
...
...
docs/images.rst
Dosyayı görüntüle @
d19572aa
...
@@ -26,10 +26,11 @@ Image objects
...
@@ -26,10 +26,11 @@ Image objects
.. autoclass:: Image()
.. autoclass:: Image()
.. autoattribute:: id
.. py:attribute:: attrs
.. autoattribute:: short_id
.. autoattribute:: id
.. autoattribute:: tags
.. autoattribute:: labels
.. py:attribute:: attrs
.. autoattribute:: short_id
.. autoattribute:: tags
The raw representation of this object from the server.
The raw representation of this object from the server.
...
...
tests/unit/fake_api.py
Dosyayı görüntüle @
d19572aa
...
@@ -134,7 +134,7 @@ def get_fake_inspect_container(tty=False):
...
@@ -134,7 +134,7 @@ def get_fake_inspect_container(tty=False):
status_code
=
200
status_code
=
200
response
=
{
response
=
{
'Id'
:
FAKE_CONTAINER_ID
,
'Id'
:
FAKE_CONTAINER_ID
,
'Config'
:
{
'Privileged'
:
True
,
'Tty'
:
tty
},
'Config'
:
{
'
Labels'
:
{
'foo'
:
'bar'
},
'
Privileged'
:
True
,
'Tty'
:
tty
},
'ID'
:
FAKE_CONTAINER_ID
,
'ID'
:
FAKE_CONTAINER_ID
,
'Image'
:
'busybox:latest'
,
'Image'
:
'busybox:latest'
,
'Name'
:
'foobar'
,
'Name'
:
'foobar'
,
...
@@ -158,6 +158,7 @@ def get_fake_inspect_image():
...
@@ -158,6 +158,7 @@ def get_fake_inspect_image():
'Parent'
:
"27cf784147099545"
,
'Parent'
:
"27cf784147099545"
,
'Created'
:
"2013-03-23T22:24:18.818426-07:00"
,
'Created'
:
"2013-03-23T22:24:18.818426-07:00"
,
'Container'
:
FAKE_CONTAINER_ID
,
'Container'
:
FAKE_CONTAINER_ID
,
'Config'
:
{
'Labels'
:
{
'bar'
:
'foo'
}},
'ContainerConfig'
:
'ContainerConfig'
:
{
{
"Hostname"
:
""
,
"Hostname"
:
""
,
...
...
tests/unit/models_containers_test.py
Dosyayı görüntüle @
d19572aa
...
@@ -384,12 +384,22 @@ class ContainerTest(unittest.TestCase):
...
@@ -384,12 +384,22 @@ class ContainerTest(unittest.TestCase):
container
.
get_archive
(
'foo'
)
container
.
get_archive
(
'foo'
)
client
.
api
.
get_archive
.
assert_called_with
(
FAKE_CONTAINER_ID
,
'foo'
)
client
.
api
.
get_archive
.
assert_called_with
(
FAKE_CONTAINER_ID
,
'foo'
)
def
test_image
(
self
):
client
=
make_fake_client
()
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
assert
container
.
image
.
id
==
FAKE_IMAGE_ID
def
test_kill
(
self
):
def
test_kill
(
self
):
client
=
make_fake_client
()
client
=
make_fake_client
()
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
container
.
kill
(
signal
=
5
)
container
.
kill
(
signal
=
5
)
client
.
api
.
kill
.
assert_called_with
(
FAKE_CONTAINER_ID
,
signal
=
5
)
client
.
api
.
kill
.
assert_called_with
(
FAKE_CONTAINER_ID
,
signal
=
5
)
def
test_labels
(
self
):
client
=
make_fake_client
()
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
assert
container
.
labels
==
{
'foo'
:
'bar'
}
def
test_logs
(
self
):
def
test_logs
(
self
):
client
=
make_fake_client
()
client
=
make_fake_client
()
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
...
...
tests/unit/models_images_test.py
Dosyayı görüntüle @
d19572aa
...
@@ -21,6 +21,11 @@ class ImageCollectionTest(unittest.TestCase):
...
@@ -21,6 +21,11 @@ class ImageCollectionTest(unittest.TestCase):
assert
isinstance
(
image
,
Image
)
assert
isinstance
(
image
,
Image
)
assert
image
.
id
==
FAKE_IMAGE_ID
assert
image
.
id
==
FAKE_IMAGE_ID
def
test_labels
(
self
):
client
=
make_fake_client
()
image
=
client
.
images
.
get
(
FAKE_IMAGE_ID
)
assert
image
.
labels
==
{
'bar'
:
'foo'
}
def
test_list
(
self
):
def
test_list
(
self
):
client
=
make_fake_client
()
client
=
make_fake_client
()
images
=
client
.
images
.
list
(
all
=
True
)
images
=
client
.
images
.
list
(
all
=
True
)
...
...
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