-
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
Conversation
Signed-off-by: Emran Batmanghelich <emran.bm@gmail.com>
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.
Thank you for the PR! I requested a couple of small changes:
- Add the
all
parameter which was added to API v1.39 at the same time: https://docs.docker.com/engine/api/v1.39/#tag/Image/operation/BuildPrune - Add a programmatic API version check before using the new parameters
docker/api/build.py
Outdated
@@ -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): |
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 as filters
and keep-storage
- let's add that as well
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.
Done!
docker/api/build.py
Outdated
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 comment
The 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 utils.version_lt
or utils.version_gte
you'll see a bunch of examples - they're not 100% consistent so do whatever makes sense here, e.g. I'm fine if there's a single check if ANY of filters
/ keep_storage
/ any
are not None
since they were all added together in the same API version)
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.
Done!
Signed-off-by: Emran Batmanghelich <emran.bm@gmail.com>
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.
Thanks for the speedy turn-around
LGTM, just needs a small fix from copy-paste 🙃
Signed-off-by: Milas Bowman <devnull@milas.dev>
Oh sorry 😢 |
Merged! Thanks for the PR! ❤️ |
Make the
api.prune_builds
method acceptfilters
andkeep-storage
args to pass to the docker API. The API details can be found here.