databricks-cli/libs/sync
Pieter Noordhuis 424499ec1d
Abstract over filesystem interaction with libs/vfs (#1452)
## Changes

Introduce `libs/vfs` for an implementation of `fs.FS` and friends that
_includes_ the absolute path it is anchored to.

This is needed for:
1. Intercepting file operations to inject custom logic (e.g., logging,
access control).
2. Traversing directories to find specific leaf directories (e.g.,
`.git`).
3. Converting virtual paths to OS-native paths.

Options 2 and 3 are not possible with the standard `fs.FS` interface.
They are needed such that we can provide an instance to the sync package
and still detect the containing `.git` directory and convert paths to
native paths.

This change focuses on making the following packages use `vfs.Path`:
* libs/fileset
* libs/git
* libs/sync

All entries returned by `fileset.All` are now slash-separated. This has
2 consequences:
* The sync snapshot now always uses slash-separated paths
* We don't need to call `filepath.FromSlash` as much as we did

## Tests

* All unit tests pass
* All integration tests pass
* Manually confirmed that a deployment made on Windows by a previous
version of the CLI can be deployed by a new version of the CLI while
retaining the validity of the local sync snapshot as well as the remote
deployment state.
2024-05-30 07:41:50 +00:00
..
testdata/sync-fileset Refactor change computation for sync (#785) 2023-10-03 13:47:46 +00:00
diff.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
diff_test.go Refactor change computation for sync (#785) 2023-10-03 13:47:46 +00:00
dirset.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
dirset_test.go Add directory tracking to sync (#425) 2023-06-12 11:44:00 +00:00
event.go Drain sync event channel before returning (#253) 2023-03-16 17:48:17 +01:00
event_test.go Add optional JSON output for sync command (#230) 2023-03-08 10:27:19 +01:00
path.go Extend deployment mode support (#577) 2023-07-30 07:19:49 +00:00
path_test.go Remove base path checks during sync (#576) 2023-07-14 11:43:20 +02:00
snapshot.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
snapshot_state.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
snapshot_state_test.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
snapshot_test.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
sync.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
sync_test.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
watchdog.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00