Skip to content

Commit b2db26a

Browse files
committed
feat: add prune_builds method with additional space management parameters
Signed-off-by: Khushiyant <[email protected]>
1 parent db7f8b8 commit b2db26a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

docker/api/build.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
275275
return self._stream_helper(response, decode=decode)
276276

277277
@utils.minimum_version('1.31')
278-
def prune_builds(self, filters=None, keep_storage=None, all=None):
278+
def prune_builds(self, filters=None, keep_storage=None, all=None, max_used_space=None, reserved_space=None, min_free_space=None):
279279
"""
280280
Delete the builder cache
281281
@@ -292,6 +292,12 @@ def prune_builds(self, filters=None, keep_storage=None, all=None):
292292
Needs Docker API v1.39+
293293
all (bool): Remove all types of build cache.
294294
Needs Docker API v1.39+
295+
reserved-space (int): The minimum amount of disk space that Docker is allowed to keep for build cache.
296+
Cache below this threshold won't be removed during garbage collection.
297+
max-used-space (int): The maximum amount of disk space that Docker is allowed to use for build cache.
298+
Any usage above this threshold will be reclaimed during garbage collection. Needs Docker API v1.48+
299+
min-free-space (int): The target amount of free disk space that the garbage collector will attempt to maintain on your system.
300+
Needs Docker API v1.48+
295301
296302
Returns:
297303
(dict): A dictionary containing information about the operation's
@@ -316,6 +322,12 @@ def prune_builds(self, filters=None, keep_storage=None, all=None):
316322
params['keep-storage'] = keep_storage
317323
if all is not None:
318324
params['all'] = all
325+
if max_used_space is not None:
326+
params['max-used-space'] = max_used_space
327+
if reserved_space is not None:
328+
params['reserved-space'] = reserved_space
329+
if min_free_space is not None:
330+
params['min-free-space'] = min_free_space
319331
return self._result(self._post(url, params=params), True)
320332

321333
def _set_auth_headers(self, headers):

0 commit comments

Comments
 (0)