mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-22 12:10:40 +00:00
Merge pull request #46 from samiam/port_to_docker_lib
Port to docker lib
This commit is contained in:
commit
091c6ea44b
@ -13,6 +13,7 @@ import docker.errors
|
|||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
|
|
||||||
from docker_custodian.args import timedelta_type
|
from docker_custodian.args import timedelta_type
|
||||||
|
from docker.utils import kwargs_from_env
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -66,7 +67,9 @@ def main():
|
|||||||
stream=sys.stdout)
|
stream=sys.stdout)
|
||||||
|
|
||||||
opts = get_opts()
|
opts = get_opts()
|
||||||
client = docker.Client(version='auto', timeout=opts.timeout)
|
client = docker.APIClient(version='auto',
|
||||||
|
timeout=opts.timeout,
|
||||||
|
**kwargs_from_env())
|
||||||
|
|
||||||
matcher = build_container_matcher(opts.prefix)
|
matcher = build_container_matcher(opts.prefix)
|
||||||
stop_containers(client, opts.max_run_time, matcher, opts.dry_run)
|
stop_containers(client, opts.max_run_time, matcher, opts.dry_run)
|
||||||
|
@ -14,6 +14,7 @@ import docker.errors
|
|||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
|
|
||||||
from docker_custodian.args import timedelta_type
|
from docker_custodian.args import timedelta_type
|
||||||
|
from docker.utils import kwargs_from_env
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -220,7 +221,9 @@ def main():
|
|||||||
stream=sys.stdout)
|
stream=sys.stdout)
|
||||||
|
|
||||||
args = get_args()
|
args = get_args()
|
||||||
client = docker.Client(version='auto', timeout=args.timeout)
|
client = docker.APIClient(version='auto',
|
||||||
|
timeout=args.timeout,
|
||||||
|
**kwargs_from_env())
|
||||||
|
|
||||||
if args.max_container_age:
|
if args.max_container_age:
|
||||||
cleanup_containers(client, args.max_container_age, args.dry_run)
|
cleanup_containers(client, args.max_container_age, args.dry_run)
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
argparse==1.3.0
|
backports.ssl-match-hostname==3.5.0.1
|
||||||
backports.ssl-match-hostname==3.4.0.2
|
certifi==2018.1.18
|
||||||
docker-py==1.7.2
|
chardet==3.0.4
|
||||||
future==0.14.3
|
docker==3.1.0
|
||||||
python-dateutil==2.4.0
|
docker-pycreds==0.2.2
|
||||||
pytimeparse==1.1.2
|
future==0.16.0
|
||||||
requests==2.7.0
|
idna==2.6
|
||||||
six==1.9.0
|
ipaddress==1.0.19
|
||||||
websocket-client==0.32.0
|
python-dateutil==2.6.1
|
||||||
|
pytimeparse==1.1.7
|
||||||
|
requests==2.18.4
|
||||||
|
six==1.11.0
|
||||||
|
urllib3==1.22
|
||||||
|
websocket-client==0.47.0
|
||||||
|
2
setup.py
2
setup.py
@ -14,7 +14,7 @@ setup(
|
|||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'python-dateutil',
|
'python-dateutil',
|
||||||
'docker-py >= 0.5',
|
'docker',
|
||||||
'pytimeparse',
|
'pytimeparse',
|
||||||
],
|
],
|
||||||
license="Apache License 2.0",
|
license="Apache License 2.0",
|
||||||
|
@ -48,6 +48,6 @@ def later_time():
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_client():
|
def mock_client():
|
||||||
client = mock.create_autospec(docker.Client)
|
client = mock.create_autospec(docker.APIClient)
|
||||||
client._version = '1.17'
|
client._version = '1.21'
|
||||||
return client
|
return client
|
||||||
|
@ -466,7 +466,7 @@ def test_build_exclude_set_empty():
|
|||||||
|
|
||||||
def test_main(mock_client):
|
def test_main(mock_client):
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
'docker_custodian.docker_gc.docker.Client',
|
'docker_custodian.docker_gc.docker.APIClient',
|
||||||
return_value=mock_client):
|
return_value=mock_client):
|
||||||
|
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
|
Loading…
Reference in New Issue
Block a user