-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add http.FileSystem migration source driver support #293
Conversation
Pull Request Test Coverage Report for Build 596
💛 - Coveralls |
Looks like markbates/pkger also implements https://blog.gobuffalo.io/introducing-pkger-static-file-embedding-in-go-1ce76dc79c65 |
This PR adds a new migration source driver capable of reading files from any source that implements http.FileSystem interface. Notable http.FileSystem interface implementations: * http.Dir() - wrapper over local file-system * github.com/shurcooL/vfsgen Because user of this package is responsible for getting an implementation of http.FileSystem, this driver does not support creating instances from driver URLs.
This PR adds a new httpfs source driver constructor New(). It is identical to the WithInstance() constructor but will postpone any errors until the driver is actually being used. This allows clients of this package to have less error checks without loosing correctness. In addition this PR adds more tests, improves test code coverage, and makes golinter happy by removing deferred Close call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
This is a good start, but the interface for httpfs.driver
should change. Namely it shouldn't implement the source.Driver
interface but instead be embedded by other structs which fully implement the source.Driver
interface.
@fln Don't force push to your branch since it makes PRs harder to review |
Thanks @dhui for reviewing and helping to push this PR forward. We are heavy users of golang-migrate/migrate package and happy to be able to contribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my feedback! Just a few more issues.
We should split up httpfs.HTTPFS
and httpfs.HTTPFSPassThrough
structs.
Examples/docs should be updated accordingly and showcase embedding.
Updated the PR to expose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the last round of feedback!
If you approve current package API I could tidy it up, squash commits and create new clean PR.
I don't think there's a need to squash commits or open a new PR since I'll do a squash an merge via github. If there's any other tidying you can think of, please feel free to do so
All review issues are resolved for the time being 🕺. |
// ErrDuplicateMigration is an error type for reporting duplicate migration | ||
// files. | ||
type ErrDuplicateMigration struct { | ||
Filename string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a source.Migration
and an os.File
instead of a filename string. I'll fix this myself to avoid an extra review roundtrip
This PR adds a new migration source driver capable of reading files from
any source that implements http.FileSystem interface.
Notable http.FileSystem interface implementations:
Because user of this package is responsible for getting an
implementation of http.FileSystem, this driver does not support creating
instances from driver URLs.