Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds a new raw file metadata storage for clients (#347)
* Added first draft for a raw json local file storage. Signed-off-by: Fredrik Skogman <[email protected]> * Ignore emacs temporary files Signed-off-by: Fredrik Skogman <[email protected]> * moved isMetaFile to util directory for reuse in other packages. Signed-off-by: Fredrik Skogman <[email protected]> * Added unit tests and refactored code to match the local store for repository side. Signed-off-by: Fredrik Skogman <[email protected]> * Added test case for non json file in metadata directory. Changed package to client to align with leveldb storage. Signed-off-by: Fredrik Skogman <[email protected]> * Use os.MkdirAll when creating metadata cache. Signed-off-by: Fredrik Skogman <[email protected]> * More consistent naming, added comments and a unit test. Signed-off-by: Fredrik Skogman <[email protected]> * Added a localstore wrapper for concurrent access. Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore_test.go Fixed spelling error found during review. Co-authored-by: Joshua Lock <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Added tests to make sure returned struct implements LocalStore interface. Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore_test.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore_test.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Made FileJSONStore safe for concurrent access. Moved IsMetaFile to new pkg, internal/fsutil Permission bits are validated when access the cache. Signed-off-by: Fredrik Skogman <[email protected]> * Spelling error. Signed-off-by: Fredrik Skogman <[email protected]> * Updates based on PR comments. Removed a test for satisfying an interface, and replaced with a compile time check. Signed-off-by: Fredrik Skogman <[email protected]> * Added first draft for a raw json local file storage. Signed-off-by: Fredrik Skogman <[email protected]> * Ignore emacs temporary files Signed-off-by: Fredrik Skogman <[email protected]> * moved isMetaFile to util directory for reuse in other packages. Signed-off-by: Fredrik Skogman <[email protected]> * Added unit tests and refactored code to match the local store for repository side. Signed-off-by: Fredrik Skogman <[email protected]> * Added test case for non json file in metadata directory. Changed package to client to align with leveldb storage. Signed-off-by: Fredrik Skogman <[email protected]> * Use os.MkdirAll when creating metadata cache. Signed-off-by: Fredrik Skogman <[email protected]> * More consistent naming, added comments and a unit test. Signed-off-by: Fredrik Skogman <[email protected]> * Added a localstore wrapper for concurrent access. Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore_test.go Fixed spelling error found during review. Co-authored-by: Joshua Lock <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Added tests to make sure returned struct implements LocalStore interface. Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore_test.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Update client/filejsonstore/filejsonstore_test.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Made FileJSONStore safe for concurrent access. Moved IsMetaFile to new pkg, internal/fsutil Permission bits are validated when access the cache. Signed-off-by: Fredrik Skogman <[email protected]> * Spelling error. Signed-off-by: Fredrik Skogman <[email protected]> * Updates based on PR comments. Removed a test for satisfying an interface, and replaced with a compile time check. Signed-off-by: Fredrik Skogman <[email protected]> * Disabled filesystem permission checks for windows. Windows filesystem permission is a bit different from UNIX like systems, and there is no good API in go to manipulate it. Nor is having these checks a requirement by the TUF spec. This commit relies on build tags to inject the correct filesystem permssion check, the Windows version always return "satisfied". Signed-off-by: Fredrik Skogman <[email protected]> * Moved the tests that rely on permission bits to a new test file. The permission bits are not executed during windows builds. Signed-off-by: Fredrik Skogman <[email protected]> * Clarify permissions check naming and comment, add tests Signed-off-by: Ethan Lowman <[email protected]> * Update internal/fsutil/fsutil.go Co-authored-by: Ethan Lowman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> * Updates based on feeback. Mostly minor things like removing sentinel errors, wrapping errors from std library. Signed-off-by: Fredrik Skogman <[email protected]> * Use fs.ErrNotExist instead of os.ErrNotExist as recommended by Go docs Signed-off-by: Ethan Lowman <[email protected]> * Clean up remaining unnecessary usage of filepath.FromSlash Signed-off-by: Ethan Lowman <[email protected]> * Add missing error checks in tests Signed-off-by: Ethan Lowman <[email protected]> * Make sure to test that returned err is nil in the tests. Signed-off-by: Fredrik Skogman <[email protected]> Signed-off-by: Fredrik Skogman <[email protected]> Signed-off-by: Ethan Lowman <[email protected]> Co-authored-by: Joshua Lock <[email protected]> Co-authored-by: Ethan Lowman <[email protected]> Co-authored-by: Ethan Lowman <[email protected]>
- Loading branch information