-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8308 from jwhonce/jira/run-976
Refactor to use DockerClient vs APIClient
- Loading branch information
Showing
8 changed files
with
187 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
from docker import APIClient | ||
from docker import DockerClient | ||
|
||
from test.python.docker import constant | ||
|
||
|
||
def run_top_container(client: APIClient): | ||
c = client.create_container( | ||
def run_top_container(client: DockerClient): | ||
c = client.containers.create( | ||
constant.ALPINE, command="top", detach=True, tty=True, name="top" | ||
) | ||
client.start(c.get("Id")) | ||
return c.get("Id") | ||
c.start() | ||
return c.id | ||
|
||
|
||
def remove_all_containers(client: APIClient): | ||
for ctnr in client.containers(quiet=True): | ||
client.remove_container(ctnr, force=True) | ||
def remove_all_containers(client: DockerClient): | ||
for ctnr in client.containers.list(all=True): | ||
ctnr.remove(force=True) | ||
|
||
|
||
def remove_all_images(client: APIClient): | ||
for image in client.images(quiet=True): | ||
client.remove_image(image, force=True) | ||
def remove_all_images(client: DockerClient): | ||
for img in client.images.list(): | ||
# FIXME should DELETE /images accept the sha256: prefix? | ||
id_ = img.id.removeprefix("sha256:") | ||
client.images.remove(id_, force=True) |
Oops, something went wrong.