Is your feature request related to a problem? Please describe.
go-bindata has been left unmaintained, unwillingly or otherwise. See
https://github.com/jteeuwen/go-bindata/issues/5
This presents a problem as we're using go-bindata to embed our migration files into our Go binaries. The next best alternative is https://github.com/gobuffalo/packr
Describe the solution you'd like
Migration source support for packr boxes.
Describe alternatives you've considered
N/A
Additional context
N/A
Threw this together quickly: https://gist.github.com/chakrit/f0f685dc224013ea3b2c3e2e8ac77a34 in case anyone wants to make a proper PR out of it.
Feel free to open a PR. Don't forget to add tests.
I can send a PR ( plus tests ) for this before Saturday
Would be awesome to get Packr support merged.
Damn, I forgot about this.... Will send in the PR on Sunday evening
Hey hey! I was just about to work on something similar.
What are your thoughts on using the ~http.FileServer~ ~webdav.FileSystem~ http.FileSystem interface so that it'll work with gobindata, fileb0x, vfsgen, and all of the other bindata packers as well?
@coolaj86 What do we gain by using another interface?
I see the following issues with using another interface/struct (http.FileServer or webdav.FS):
migrate.source.Driver interface.http.FileServer or webdav.FS provide a method for listing files.migrate.source.Driverhttp+go-bindata:// or webdav+go-bindata:// instead of go-bindata://Hey @coolaj86, let me know if you are picking this one up
@dhui @adelowo This is what I meant: https://github.com/golang-migrate/migrate/pull/144
Obviously you'll want more docs and whatnot, but that shows how it could work.
http.FileSystem is the "canonical" FileSystem implementation that almost everyone who is making any sort of FS abstraction conforms to. It only differs from os.Open and os.File.Readdir in that it's an interface rather than a struct. Or at least I think I said that right.
The interface needs to provide a way to "list" files which is necessary to read the next/previous migration to run. See the migrate.source.Driver interface. It doesn't look like http.FileServer or webdav.FS provide a method for listing files.
They both use http.File which must implement http.File.Readdir (same as os.Readdir).
ioutil.ReadDir is just a convenience wrapper over os.Readdir. Whereas the os package defines a singleton with several wrappers, http.File defines an interface. An os.File implements http.File.
Intuitively, you'd think that http.File would implement an interface from os, not the other way around... but that's just how the cookie crumbled as the language evolved.
Using another interface won't save any work since you'll need to integrate the bin packer with the other interface, which should be roughly the same amount of work as integrating with migrate.source.Driver
The point is that packr, fileb0x, vfsgen, and most other bindata generators _already_ implement http.FileSystem and/or webdav.FileSystem, so there's no need to do any work.
The plugins for packr and fileb0x that I included in my PR are essentially no-op wrappers. The only reason to have such a plugin is for SEO benefit and for the benefit of people who didn't read or understand the documentation of those packages as implementing the http.FileSystem and webdav.FileSystem interfaces (which I didn't understand at first either).
Specifying the source driver would stumble. e.g. the schema would look something like http+go-bindata:// or webdav+go-bindata:// instead of go-bindata://
It's all the same interface (see the code in the PR). A single fs:// namespace would handle all cases. The only reason to have separate names would be for the benefit of documentation and SEO.
A single fs:// namespace would handle all cases. The only reason to have separate names would be for the benefit of documentation and SEO.
I believe we'll still need to register the each source driver for the following reasons:
packr, fileb0x, etcThis should be trivial to implement now that #293 has been merged.
Also, it looks like there's yet another packer/packager...
https://github.com/markbates/pkger
Closing since pkgr is supported. If anyone wants packr support, they can still open a PR and add it.
Most helpful comment
They both use
http.Filewhich must implementhttp.File.Readdir(same asos.Readdir).ioutil.ReadDiris just a convenience wrapper overos.Readdir. Whereas theospackage defines a singleton with several wrappers,http.Filedefines an interface. Anos.Fileimplementshttp.File.Intuitively, you'd think that
http.Filewould implement an interface fromos, not the other way around... but that's just how the cookie crumbled as the language evolved.The point is that packr, fileb0x, vfsgen, and most other bindata generators _already_ implement
http.FileSystemand/orwebdav.FileSystem, so there's no need to do any work.The plugins for packr and fileb0x that I included in my PR are essentially no-op wrappers. The only reason to have such a plugin is for SEO benefit and for the benefit of people who didn't read or understand the documentation of those packages as implementing the
http.FileSystemandwebdav.FileSysteminterfaces (which I didn't understand at first either).It's all the same interface (see the code in the PR). A single
fs://namespace would handle all cases. The only reason to have separate names would be for the benefit of documentation and SEO.