mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-29 07:30:35 +00:00
commit
eb94d2b9a5
@ -1,6 +1,6 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v1.2.3
|
rev: v2.2.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-docstring-first
|
- id: check-docstring-first
|
||||||
@ -14,7 +14,7 @@ repos:
|
|||||||
- id: requirements-txt-fixer
|
- id: requirements-txt-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: git://github.com/Yelp/detect-secrets
|
- repo: git://github.com/Yelp/detect-secrets
|
||||||
rev: 0.9.1
|
rev: v0.12.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: detect-secrets
|
- id: detect-secrets
|
||||||
args: ['--baseline', '.secrets.baseline']
|
args: ['--baseline', '.secrets.baseline']
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"exclude_regex": "tests/.*",
|
"exclude": {
|
||||||
"generated_at": "2018-07-12T23:43:31Z",
|
"files": "tests/.*",
|
||||||
|
"lines": null
|
||||||
|
},
|
||||||
|
"generated_at": "2019-04-24T14:36:38Z",
|
||||||
"plugins_used": [
|
"plugins_used": [
|
||||||
{
|
{
|
||||||
"base64_limit": 4.5,
|
"base64_limit": 4.5,
|
||||||
@ -15,5 +18,5 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"results": {},
|
"results": {},
|
||||||
"version": "0.9.1"
|
"version": "0.12.2"
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ def filter_excluded_containers(containers, exclude_container_labels):
|
|||||||
|
|
||||||
|
|
||||||
def should_exclude_container_with_labels(container, exclude_container_labels):
|
def should_exclude_container_with_labels(container, exclude_container_labels):
|
||||||
|
if container['Labels']:
|
||||||
for exclude_label in exclude_container_labels:
|
for exclude_label in exclude_container_labels:
|
||||||
if exclude_label.value:
|
if exclude_label.value:
|
||||||
matching_keys = fnmatch.filter(
|
matching_keys = fnmatch.filter(
|
||||||
@ -89,7 +90,10 @@ def should_exclude_container_with_labels(container, exclude_container_labels):
|
|||||||
if fnmatch.filter(label_values_to_check, exclude_label.value):
|
if fnmatch.filter(label_values_to_check, exclude_label.value):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if fnmatch.filter(container['Labels'].keys(), exclude_label.key):
|
if fnmatch.filter(
|
||||||
|
container['Labels'].keys(),
|
||||||
|
exclude_label.key
|
||||||
|
):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ def test_filter_excluded_containers():
|
|||||||
{'Labels': {'too': 'lol'}},
|
{'Labels': {'too': 'lol'}},
|
||||||
{'Labels': {'toots': 'lol'}},
|
{'Labels': {'toots': 'lol'}},
|
||||||
{'Labels': {'foo': 'bar'}},
|
{'Labels': {'foo': 'bar'}},
|
||||||
|
{'Labels': None},
|
||||||
]
|
]
|
||||||
result = docker_gc.filter_excluded_containers(mock_containers, None)
|
result = docker_gc.filter_excluded_containers(mock_containers, None)
|
||||||
assert mock_containers == list(result)
|
assert mock_containers == list(result)
|
||||||
@ -86,7 +87,11 @@ def test_filter_excluded_containers():
|
|||||||
mock_containers,
|
mock_containers,
|
||||||
exclude_labels,
|
exclude_labels,
|
||||||
)
|
)
|
||||||
assert [mock_containers[0], mock_containers[2]] == list(result)
|
assert [
|
||||||
|
mock_containers[0],
|
||||||
|
mock_containers[2],
|
||||||
|
mock_containers[4]
|
||||||
|
] == list(result)
|
||||||
exclude_labels = [
|
exclude_labels = [
|
||||||
docker_gc.ExcludeLabel(key='too*', value='lol'),
|
docker_gc.ExcludeLabel(key='too*', value='lol'),
|
||||||
]
|
]
|
||||||
@ -94,7 +99,11 @@ def test_filter_excluded_containers():
|
|||||||
mock_containers,
|
mock_containers,
|
||||||
exclude_labels,
|
exclude_labels,
|
||||||
)
|
)
|
||||||
assert [mock_containers[0], mock_containers[3]] == list(result)
|
assert [
|
||||||
|
mock_containers[0],
|
||||||
|
mock_containers[3],
|
||||||
|
mock_containers[4]
|
||||||
|
] == list(result)
|
||||||
|
|
||||||
|
|
||||||
def test_cleanup_images(mock_client, now):
|
def test_cleanup_images(mock_client, now):
|
||||||
|
Loading…
Reference in New Issue
Block a user