Skip to content

Commit

Permalink
core: add support for wipe arg to Directory.export (#6909)
Browse files Browse the repository at this point in the history
* core: add support for wipe arg to Directory.export

By default, exporting a directory resulted in its contents being merged
into the target directory on the host, with any files that existed on
the host but not in the source dir being untouched during the export.

More often than not, this is the behavior you want, but there are use
cases where you'd instead like to replace the contents of the host
directory entirely such that it exactly matches the source dir being
exported. This enables you to e.g. load a dir from the host, delete some
files from it and then export that back to the host with those deletes
being reflected.

This change adds an arg to `Directory.export` to enable that behavior.

I really wanted to name the arg `merge` and default it to `true`, but it
turns out that doesn't really work for optional args since at least the
Go SDK can't distinguish between an explicit `false` value on an
optional arg and an explicitly set `false`, so it wasn't possible to
ever get anything but the `merge: true` behavior. Didn't check other
SDKs but I would imagine at least a few of them have the same sort of
problem.

So I fell back to just naming the arg `wipe` and making it trigger
the non-default behavior only when set to true.

Signed-off-by: Erik Sipsma <erik@dagger.io>

* update phrasing in wipe docs

Signed-off-by: Erik Sipsma <erik@dagger.io>

---------

Signed-off-by: Erik Sipsma <erik@dagger.io>
  • Loading branch information
sipsma authored Mar 22, 2024
1 parent 3faa7ec commit 6e69315
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dagger.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6e69315

Please sign in to comment.