-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: accept filters and keep_storage in prune_builds #3192
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Emran Batmanghelich <emran.bm@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,10 +276,20 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None, | |
return self._stream_helper(response, decode=decode) | ||
|
||
@utils.minimum_version('1.31') | ||
def prune_builds(self): | ||
def prune_builds(self, filters=None, keep_storage=None): | ||
""" | ||
Delete the builder cache | ||
|
||
Args: | ||
filters (dict): Filters to process on the prune list. | ||
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. | ||
|
||
Returns: | ||
(dict): A dictionary containing information about the operation's | ||
result. The ``SpaceReclaimed`` key indicates the amount of | ||
|
@@ -290,7 +300,12 @@ def prune_builds(self): | |
If the server returns an error. | ||
""" | ||
url = self._url("/build/prune") | ||
return self._result(self._post(url), True) | ||
params = {} | ||
if filters is not None: | ||
params['filters'] = utils.convert_filters(filters) | ||
if keep_storage is not None: | ||
params['keep-storage'] = keep_storage | ||
return self._result(self._post(url, params=params), True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These args were added in API v1.39 - typically, we add a check for them, e.g. if utils.version_lt(self._version, '1.39'):
raise errors.InvalidVersion(
'`keep-storage` arg only available for API version > 1.38'
) (if you look for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
|
||
def _set_auth_headers(self, headers): | ||
log.debug('Looking for auth config') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also
all
, which is a boolean and was added at the same time asfilters
andkeep-storage
- let's add that as wellThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!