genuinetools / img

Standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder.
https://blog.jessfraz.com/post/building-container-images-securely-on-kubernetes/
MIT License
3.9k stars 231 forks source link

Fix "prune" subcommand #322

Closed ahamlinman closed 3 years ago

ahamlinman commented 3 years ago

The current implementation of img prune does not actually remove any data. This changeset introduces an extra variadic argument to the Prune call, producing behavior equivalent to buildctl prune invoked without flags against a BuildKit daemon.

I think the issue and proposed fix become more clear with a look at the underlying implementation, which loops over the variadic PruneInfo arguments and runs a prune operation based on options specified in each argument. With no arguments, it skips the loop and only runs the final garbage collection on the metadata store.

https://github.com/genuinetools/img/blob/d858ac71f93cc5084edd2ba2d425b90234cf2ead/vendor/github.com/moby/buildkit/cache/manager.go#L515-L520

I believe this resolves #153 and resolves #320.