Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(storage/fs): change fs.FSSource into fs.SnapshotSource #2325

Merged
merged 6 commits into from
Nov 1, 2023

Conversation

GeorgeMac
Copy link
Contributor

This refactors the fs.Store implementation to work over a new type fs.SnapshoutSource instead of fs.FSSource.

The difference between these abstractions is instead of returning fs.FS interface implementations, this source returns the full snapshots. The benefit here is the source can decide how to build the snapshot. Instead of having to conform to fs.FS. The storage fs.SnapshotFromFS can still be used to turn any fs.FS into a snapshot.

All the existing sources have just been updated to call this utility function to adapt their existing fs.FS implementations.
Future implementations don't have to use this abstraction and we can change existing ones if and when it makes sense.

The last thing it does is expose a new SnapshotFromFiles method.
This method just takes a slice of fs.File instead of the full fs.FS.
The fs.File interface is actually quite appropriate and more approachable than the full fs.FS abstraction.
It will be necessary for both reading contents and for identifying file extension (to support both Yaml and JSON).

The OCI implementation will skip the fs.FS abstraction and use just the fs.File implementation instead.
I can update all the open FS issues to reference these new abstractions instead.

@GeorgeMac GeorgeMac requested a review from a team as a code owner November 1, 2023 15:37
Copy link
Contributor

github-actions bot commented Nov 1, 2023

Uffizzi Preview deployment-39955 was deleted.

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this abstraction!

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Merging #2325 (06cc939) into main (85e5f3a) will increase coverage by 0.05%.
The diff coverage is 75.32%.

@@            Coverage Diff             @@
##             main    #2325      +/-   ##
==========================================
+ Coverage   70.87%   70.92%   +0.05%     
==========================================
  Files          78       78              
  Lines        7436     7449      +13     
==========================================
+ Hits         5270     5283      +13     
+ Misses       1866     1865       -1     
- Partials      300      301       +1     
Files Coverage Δ
internal/storage/fs/local/source.go 91.17% <100.00%> (+0.26%) ⬆️
internal/storage/fs/store.go 94.00% <100.00%> (+14.68%) ⬆️
internal/storage/fs/s3/source.go 76.71% <70.00%> (-2.70%) ⬇️
internal/storage/fs/git/source.go 79.77% <61.53%> (-2.16%) ⬇️
internal/storage/fs/snapshot.go 70.28% <71.79%> (-0.05%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@GeorgeMac GeorgeMac merged commit 3504651 into main Nov 1, 2023
30 checks passed
@GeorgeMac GeorgeMac deleted the gm/fs-refactor-sources branch November 1, 2023 17:31
@GeorgeMac GeorgeMac temporarily deployed to uffizzi November 1, 2023 17:31 — with GitHub Actions Inactive
markphelps added a commit that referenced this pull request Nov 1, 2023
* 'main' of https://github.com/flipt-io/flipt:
  refactor(storage/fs): change fs.FSSource into fs.SnapshotSource (#2325)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants