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
32bc17e1
Kaydet (Commit)
32bc17e1
authored
Ock 25, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add 'force' parameter in remove_volume
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
f7040822
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
7 deletions
+33
-7
volume.py
docker/api/volume.py
+14
-4
volumes.py
docker/models/volumes.py
+12
-3
api_volume_test.py
tests/integration/api_volume_test.py
+7
-0
No files found.
docker/api/volume.py
Dosyayı görüntüle @
32bc17e1
...
@@ -117,17 +117,27 @@ class VolumeApiMixin(object):
...
@@ -117,17 +117,27 @@ class VolumeApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
),
True
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.minimum_version
(
'1.21'
)
@utils.minimum_version
(
'1.21'
)
def
remove_volume
(
self
,
name
):
def
remove_volume
(
self
,
name
,
force
=
False
):
"""
"""
Remove a volume. Similar to the ``docker volume rm`` command.
Remove a volume. Similar to the ``docker volume rm`` command.
Args:
Args:
name (str): The volume's name
name (str): The volume's name
force (bool): Force removal of volumes that were already removed
out of band by the volume driver plugin.
Raises:
Raises:
:py:class:`docker.errors.APIError`
``docker.errors.APIError``:
If volume failed to remove.
If volume failed to remove.
"""
"""
url
=
self
.
_url
(
'/volumes/{0}'
,
name
)
params
=
{}
if
force
:
if
utils
.
version_lt
(
self
.
_version
,
'1.25'
):
raise
errors
.
InvalidVersion
(
'force removal was introduced in API 1.25'
)
params
=
{
'force'
:
force
}
url
=
self
.
_url
(
'/volumes/{0}'
,
name
,
params
=
params
)
resp
=
self
.
_delete
(
url
)
resp
=
self
.
_delete
(
url
)
self
.
_raise_for_status
(
resp
)
self
.
_raise_for_status
(
resp
)
docker/models/volumes.py
Dosyayı görüntüle @
32bc17e1
...
@@ -10,9 +10,18 @@ class Volume(Model):
...
@@ -10,9 +10,18 @@ class Volume(Model):
"""The name of the volume."""
"""The name of the volume."""
return
self
.
attrs
[
'Name'
]
return
self
.
attrs
[
'Name'
]
def
remove
(
self
):
def
remove
(
self
,
force
=
False
):
"""Remove this volume."""
"""
return
self
.
client
.
api
.
remove_volume
(
self
.
id
)
Remove this volume.
Args:
force (bool): Force removal of volumes that were already removed
out of band by the volume driver plugin.
Raises:
:py:class:`docker.errors.APIError`
If volume failed to remove.
"""
return
self
.
client
.
api
.
remove_volume
(
self
.
id
,
force
=
force
)
class
VolumeCollection
(
Collection
):
class
VolumeCollection
(
Collection
):
...
...
tests/integration/api_volume_test.py
Dosyayı görüntüle @
32bc17e1
...
@@ -49,6 +49,13 @@ class TestVolumes(BaseAPIIntegrationTest):
...
@@ -49,6 +49,13 @@ class TestVolumes(BaseAPIIntegrationTest):
self
.
client
.
create_volume
(
name
)
self
.
client
.
create_volume
(
name
)
self
.
client
.
remove_volume
(
name
)
self
.
client
.
remove_volume
(
name
)
@requires_api_version
(
'1.25'
)
def
test_force_remove_volume
(
self
):
name
=
'shootthebullet'
self
.
tmp_volumes
.
append
(
name
)
self
.
client
.
create_volume
(
name
)
self
.
client
.
remove_volume
(
name
,
force
=
True
)
def
test_remove_nonexistent_volume
(
self
):
def
test_remove_nonexistent_volume
(
self
):
name
=
'shootthebullet'
name
=
'shootthebullet'
with
pytest
.
raises
(
docker
.
errors
.
NotFound
):
with
pytest
.
raises
(
docker
.
errors
.
NotFound
):
...
...
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