Skip to content
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

image prune command fixed as per docker image prune. #4512

Merged
merged 4 commits into from Nov 22, 2019

Conversation

kunalkushwaha
Copy link
Collaborator

@kunalkushwaha kunalkushwaha commented Nov 14, 2019

makes podman image prune aligned with docker image prune command.

This PR makes following changes.

  • default podman image prune now ask for confirmation from user with warning message.
$ .podman image prune

WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] 
$ podman image prune -a --filter until=2019-11-14T06:15:42.937792374Z             

WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] 

$ podman image prune -a --filter until=10h                            

WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] 

Signed-off-by: Kunal Kushwaha kunal.kushwaha@gmail.com

Warning message added before executing image prune
Added a force option, to execute without user input.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
timetype package include functions for calculating
time input in string as one of golang duration format and
calculate as unix timestamp

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
@TomSweeneyRedHat
Copy link
Member

@kunalkushwaha you've a gofmt issue, you need to run:
gofmt -s -w image/image.go then add, commit and push. Did you sign the commit too?
Anywho, look like a nice change overall, thanks for putting it together.

@baude
Copy link
Member

baude commented Nov 14, 2019

you can also just run make validate

@kunalkushwaha kunalkushwaha changed the title Prune filter image prune command fixed as per docker image prune. Nov 19, 2019
@kunalkushwaha
Copy link
Collaborator Author

@TomSweeneyRedHat @baude All tests are green now. PTAL

@rhatdan
Copy link
Member

rhatdan commented Nov 20, 2019

// Filter is a function to determine whether a image is included
// in command output. Images to be outputted are tested using the function.
// A true return will include the image, a false return will exclude it.
type Filter func(*Image) bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to ImageFilter? I can see us adding Container filters and Pod filters in the future, too, which might give us name collisions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially named this Filter as ImageFilter. But make validate reports error as its part of image package and user need to use image.ImageFilter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we either tell validate to be quiet or make it plural
ImagesFilter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. used //nolint for ignoring the check against ImageFilter

// GetPruneImages returns a slice of images that have no names/unused
func (ir *Runtime) GetPruneImages(all bool) ([]*Image, error) {
func (ir *Runtime) GetPruneImages(all bool, filters []string) ([]*Image, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have this accept a []ImageFilter instead, and converting from string to filter earlier.

@TomSweeneyRedHat
Copy link
Member

code changes LGTM other than @mheon's comments.
Missing changes to man pages(docs/source/markdown/podman-image-prune.1.md) and bash completions (completions/bash/podman).

@TomSweeneyRedHat
Copy link
Member

and most importantly, THANKS @kunalkushwaha for this pr. It will be a nice add to Podman once complete.

@mheon
Copy link
Member

mheon commented Nov 20, 2019

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kunalkushwaha, mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2019
filter option accepts two filters.
- label
- until
label supports "label=value" or "label=key=value" format
until supports all golang compatible time/duration formats.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
@kunalkushwaha kunalkushwaha force-pushed the prune-filter branch 2 times, most recently from 6fd69ac to e38fd8e Compare November 22, 2019 08:41
examples of image prune with filter and
until options added

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
@TomSweeneyRedHat
Copy link
Member

Our old friend the prune remote test is failing again, restarting.

@TomSweeneyRedHat
Copy link
Member

LGTM if we can get the tests happy. Current test issues I don't believe are related to this PR.

@rhatdan
Copy link
Member

rhatdan commented Nov 22, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2019
@openshift-merge-robot openshift-merge-robot merged commit ef240f4 into containers:master Nov 22, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support --filter flag in podman image prune Support -f/--force flag in podman image prune
7 participants