compose/pkg
Milas Bowman 105a7c5b70 watch: add file delete/rename handling
This approach mimics Tilt's behavior[^1]:
 1. At sync time, `stat` the path on host
 2. If the path does not exist -> `rm` from container
 3. If the path exists -> sync to container

By handling things this way, we're always syncing based on the true
state, regardless of what's happened in the interim. For example, a
common pattern in POSIX tools is to create a file and then rename it
over an existing file. Based on timing, this could be a sync, delete,
sync (every file gets seen & processed) OR a delete, sync (by the
the time we process the event, the "temp" file is already gone, so
we just delete it from the container, where it never existed, but
that's fine since we deletes are idempotent thanks to the `-f` flag
on `rm`).

Additionally, when syncing, if the `stat` call shows it's for a
directory, we ignore it. Otherwise, duplicate, nested copies of the
entire path could get synced in. (On some OSes, an event for the
directory gets dispatched when a file inside of it is modified. In
practice, I think we might want this pushed further down in the
watching code, but since we're already `stat`ing the paths here now,
it's a good place to handle it.)

Lastly, there's some very light changes to the text when it does a
full rebuild that will list out the (merged) set of paths that
triggered it. We can continue to improve the output, but this is
really helpful for understanding why it's rebuilding.

[^1]: db7f887b06/internal/controllers/core/liveupdate/reconciler.go (L911)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-21 08:37:18 -04:00
..
api add dry-run support for push command 2023-03-08 14:23:57 +00:00
compose watch: add file delete/rename handling 2023-03-21 08:37:18 -04:00
e2e one off container name use configured Separator for naming 2023-03-15 09:47:43 +01:00
mocks bump docker engine and cli version to 23.0.0 with buildkit(v0.11.2) and buildx (v0.10.2) 2023-02-08 10:11:50 +01:00
progress progress writer uses dockercli.Err stream 2023-03-15 09:47:13 +01:00
prompt use a simpler prompt implementation when we lack a terminal 2023-01-09 10:28:16 +01:00
utils detect replacement container is created and inform printer so it attach and don't stop 2023-02-06 11:23:13 +01:00
watch watch: ignore ephemeral files & minor output tweaks 2023-02-24 14:34:51 -05:00