mirror of https://github.com/docker/docker-py.git
feat: accept all / filters / keep_storage in prune_builds (#3192)
Added in API v1.39. --------- Signed-off-by: Emran Batmanghelich <emran.bm@gmail.com>
This commit is contained in:
parent
a9b5494fd0
commit
3d0a3f1d77
|
@ -279,10 +279,24 @@ class BuildApiMixin:
|
||||||
return self._stream_helper(response, decode=decode)
|
return self._stream_helper(response, decode=decode)
|
||||||
|
|
||||||
@utils.minimum_version('1.31')
|
@utils.minimum_version('1.31')
|
||||||
def prune_builds(self):
|
def prune_builds(self, filters=None, keep_storage=None, all=None):
|
||||||
"""
|
"""
|
||||||
Delete the builder cache
|
Delete the builder cache
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filters (dict): Filters to process on the prune list.
|
||||||
|
Needs Docker API v1.39+
|
||||||
|
Available filters:
|
||||||
|
- dangling (bool): When set to true (or 1), prune only
|
||||||
|
unused and untagged images.
|
||||||
|
- until (str): Can be Unix timestamps, date formatted
|
||||||
|
timestamps, or Go duration strings (e.g. 10m, 1h30m) computed
|
||||||
|
relative to the daemon's local time.
|
||||||
|
keep_storage (int): Amount of disk space in bytes to keep for cache.
|
||||||
|
Needs Docker API v1.39+
|
||||||
|
all (bool): Remove all types of build cache.
|
||||||
|
Needs Docker API v1.39+
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(dict): A dictionary containing information about the operation's
|
(dict): A dictionary containing information about the operation's
|
||||||
result. The ``SpaceReclaimed`` key indicates the amount of
|
result. The ``SpaceReclaimed`` key indicates the amount of
|
||||||
|
@ -293,7 +307,20 @@ class BuildApiMixin:
|
||||||
If the server returns an error.
|
If the server returns an error.
|
||||||
"""
|
"""
|
||||||
url = self._url("/build/prune")
|
url = self._url("/build/prune")
|
||||||
return self._result(self._post(url), True)
|
if (filters, keep_storage, all) != (None, None, None) \
|
||||||
|
and utils.version_lt(self._version, '1.39'):
|
||||||
|
raise errors.InvalidVersion(
|
||||||
|
'`filters`, `keep_storage`, and `all` args are only available '
|
||||||
|
'for API version > 1.38'
|
||||||
|
)
|
||||||
|
params = {}
|
||||||
|
if filters is not None:
|
||||||
|
params['filters'] = utils.convert_filters(filters)
|
||||||
|
if keep_storage is not None:
|
||||||
|
params['keep-storage'] = keep_storage
|
||||||
|
if all is not None:
|
||||||
|
params['all'] = all
|
||||||
|
return self._result(self._post(url, params=params), True)
|
||||||
|
|
||||||
def _set_auth_headers(self, headers):
|
def _set_auth_headers(self, headers):
|
||||||
log.debug('Looking for auth config')
|
log.debug('Looking for auth config')
|
||||||
|
|
Loading…
Reference in New Issue