exporter: add local exporter mode=delete#6561
Open
crazy-max wants to merge 1 commit intomoby:masterfrom
Open
Conversation
48e766e to
071d3cf
Compare
477e40e to
22b3c81
Compare
tonistiigi
reviewed
Mar 6, 2026
Member
tonistiigi
left a comment
There was a problem hiding this comment.
I'd call it delete like rsync --delete. In Buildx I think we need more restrictions. I'd only allow it for subdirs there, with a second-level opt-in needed to mess with the main workdir or things outside it.
Member
Author
Agreed, renamed the mode from |
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
22b3c81 to
80b1312
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
partially fixes #2805
This PR adds support for a
modeattribute on the local exporter output path.The default behavior remains
mode=copy, which preserves destination files that are not present in the exported result. A newmode=deletebehavior is added so the destination matches the exported result by removing stale files and directories.Because
mode=deletecan remove files under the destination directory, this feature is intentionally explicit opt-in and should be used only with trusted build definitions and carefully reviewed output destinations.On client side like Buildx we should probably have some safety gate like
--allow local-output-delete(or equivalent) for remote Bake invocations. Optionally block/require explicit allow whendest=.withmode=delete?Maybe we could have some kind of scope attribute like
mode=delete,delete-scope=dist,assetsso it only deletes stale files under those relative paths (and reject unsafe scopes like..or absolute paths)?Also the
backupmode from the issue is intentionally left for a follow-up change. I think we would need changes infsutil.Receive(or diff callbacks).